diff options
author | Michael Brown | 2017-03-21 13:46:19 +0100 |
---|---|---|
committer | Michael Brown | 2017-03-21 13:46:19 +0100 |
commit | 2ae759219b4a0f461284bf6e386ece58307ad6f0 (patch) | |
tree | fe69969f6d4912d11a3c3635d05eb48a8243cf8e /src/hci | |
parent | [mucurses] Attempt to fix keypress processing logic (diff) | |
download | ipxe-2ae759219b4a0f461284bf6e386ece58307ad6f0.tar.gz ipxe-2ae759219b4a0f461284bf6e386ece58307ad6f0.tar.xz ipxe-2ae759219b4a0f461284bf6e386ece58307ad6f0.zip |
[mucurses] Attempt to fix resource leaks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r-- | src/hci/mucurses/windows.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/hci/mucurses/windows.c b/src/hci/mucurses/windows.c index 5f5d1f4e..090fcfd2 100644 --- a/src/hci/mucurses/windows.c +++ b/src/hci/mucurses/windows.c @@ -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; @@ -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; @@ -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; |