|
@@ -51,10 +51,11 @@ WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
|
51
|
51
|
WINDOW *child;
|
52
|
52
|
if ( parent == NULL )
|
53
|
53
|
return NULL;
|
|
54
|
+ if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
|
|
55
|
+ return NULL;
|
54
|
56
|
if ( ( (unsigned)ncols > parent->width ) ||
|
55
|
57
|
( (unsigned)nlines > parent->height ) )
|
56
|
58
|
return NULL;
|
57
|
|
- child = malloc( sizeof( WINDOW ) );
|
58
|
59
|
child->ori_y = parent->ori_y + begin_y;
|
59
|
60
|
child->ori_x = parent->ori_x + begin_x;
|
60
|
61
|
child->height = nlines;
|
|
@@ -74,7 +75,8 @@ WINDOW *dupwin ( WINDOW *orig ) {
|
74
|
75
|
WINDOW *copy;
|
75
|
76
|
if ( orig == NULL )
|
76
|
77
|
return NULL;
|
77
|
|
- copy = malloc( sizeof( WINDOW ) );
|
|
78
|
+ if ( ( copy = malloc( sizeof( WINDOW ) ) ) == NULL )
|
|
79
|
+ return NULL;
|
78
|
80
|
copy->scr = orig->scr;
|
79
|
81
|
copy->attrs = orig->attrs;
|
80
|
82
|
copy->ori_y = orig->ori_y;
|
|
@@ -117,7 +119,9 @@ int mvwin ( WINDOW *win, int y, int x ) {
|
117
|
119
|
* @ret *win return pointer to new window
|
118
|
120
|
*/
|
119
|
121
|
WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
|
120
|
|
- WINDOW *win = malloc( sizeof(WINDOW) );
|
|
122
|
+ WINDOW *win;
|
|
123
|
+ if ( ( win = malloc( sizeof(WINDOW) ) ) == NULL )
|
|
124
|
+ return NULL;
|
121
|
125
|
if ( ( (unsigned)( begin_y + nlines ) > stdscr->height ) &&
|
122
|
126
|
( (unsigned)( begin_x + ncols ) > stdscr->width ) )
|
123
|
127
|
return NULL;
|
|
@@ -145,7 +149,8 @@ WINDOW *subwin ( WINDOW *parent, int nlines, int ncols,
|
145
|
149
|
WINDOW *child;
|
146
|
150
|
if ( parent == NULL )
|
147
|
151
|
return NULL;
|
148
|
|
- child = malloc( sizeof( WINDOW ) );
|
|
152
|
+ if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
|
|
153
|
+ return NULL;
|
149
|
154
|
child = newwin( nlines, ncols, begin_y, begin_x );
|
150
|
155
|
child->parent = parent;
|
151
|
156
|
child->scr = parent->scr;
|