Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mucurses] Attempt to fix resource leaks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 21, 2017
1 parent 583d258 commit 2ae7592
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/hci/mucurses/windows.c
Expand Up @@ -48,11 +48,11 @@ int delwin ( WINDOW *win ) {
WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
int begin_y, int begin_x ) {
WINDOW *child;
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
if ( ( (unsigned)ncols > parent->width ) ||
( (unsigned)nlines > parent->height ) )
return NULL;
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
child->ori_y = parent->ori_y + begin_y;
child->ori_x = parent->ori_x + begin_x;
child->height = nlines;
Expand Down Expand Up @@ -113,11 +113,11 @@ int mvwin ( WINDOW *win, int y, int x ) {
*/
WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
WINDOW *win;
if ( ( win = malloc( sizeof(WINDOW) ) ) == NULL )
return NULL;
if ( ( (unsigned)( begin_y + nlines ) > stdscr->height ) &&
( (unsigned)( begin_x + ncols ) > stdscr->width ) )
return NULL;
if ( ( win = malloc( sizeof(WINDOW) ) ) == NULL )
return NULL;
win->ori_y = begin_y;
win->ori_x = begin_x;
win->height = nlines;
Expand All @@ -140,8 +140,6 @@ WINDOW *newwin ( int nlines, int ncols, int begin_y, int begin_x ) {
WINDOW *subwin ( WINDOW *parent, int nlines, int ncols,
int begin_y, int begin_x ) {
WINDOW *child;
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
child = newwin( nlines, ncols, begin_y, begin_x );
child->parent = parent;
child->scr = parent->scr;
Expand Down

0 comments on commit 2ae7592

Please sign in to comment.