diff options
author | ache <ache@FreeBSD.org> | 1994-10-31 04:02:31 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-10-31 04:02:31 +0000 |
commit | cc17583236592182ca8e3ea587e136728670cde3 (patch) | |
tree | 115afe490333a65e6fee8362c8433184afeb7fd3 /gnu | |
parent | 669c3d9a1acb2a3f2988ea2f4ef09813cd84cab7 (diff) | |
download | FreeBSD-src-cc17583236592182ca8e3ea587e136728670cde3.zip FreeBSD-src-cc17583236592182ca8e3ea587e136728670cde3.tar.gz |
Add pointer check after each newwin/subwin with error diagnostic
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/lib/libdialog/checklist.c | 10 | ||||
-rw-r--r-- | gnu/lib/libdialog/inputbox.c | 5 | ||||
-rw-r--r-- | gnu/lib/libdialog/menubox.c | 10 | ||||
-rw-r--r-- | gnu/lib/libdialog/msgbox.c | 5 | ||||
-rw-r--r-- | gnu/lib/libdialog/prgbox.c | 5 | ||||
-rw-r--r-- | gnu/lib/libdialog/radiolist.c | 10 | ||||
-rw-r--r-- | gnu/lib/libdialog/textbox.c | 10 | ||||
-rw-r--r-- | gnu/lib/libdialog/yesno.c | 5 |
8 files changed, 60 insertions, 0 deletions
diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c index f802f33..cc83d25 100644 --- a/gnu/lib/libdialog/checklist.c +++ b/gnu/lib/libdialog/checklist.c @@ -59,6 +59,11 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); @@ -91,6 +96,11 @@ int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, in /* create new window for the list */ list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1); + if (list == NULL) { + endwin(); + fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height,list_width,y+box_y+1,x+box_x+1); + exit(1); + } keypad(list, TRUE); /* draw a box around the list items */ diff --git a/gnu/lib/libdialog/inputbox.c b/gnu/lib/libdialog/inputbox.c index bf423c9..8bf384d 100644 --- a/gnu/lib/libdialog/inputbox.c +++ b/gnu/lib/libdialog/inputbox.c @@ -42,6 +42,11 @@ int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); diff --git a/gnu/lib/libdialog/menubox.c b/gnu/lib/libdialog/menubox.c index 332dfa7..5aa5b5b 100644 --- a/gnu/lib/libdialog/menubox.c +++ b/gnu/lib/libdialog/menubox.c @@ -49,6 +49,11 @@ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int wid draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); @@ -81,6 +86,11 @@ int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int wid /* create new window for the menu */ menu = subwin(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); + if (menu == NULL) { + endwin(); + fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", menu_height,menu_width,y+box_y+1,x+box_x+1); + exit(1); + } keypad(menu, TRUE); /* draw a box around the menu items */ diff --git a/gnu/lib/libdialog/msgbox.c b/gnu/lib/libdialog/msgbox.c index c56b58b..e405f3b 100644 --- a/gnu/lib/libdialog/msgbox.c +++ b/gnu/lib/libdialog/msgbox.c @@ -41,6 +41,11 @@ int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int w draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); diff --git a/gnu/lib/libdialog/prgbox.c b/gnu/lib/libdialog/prgbox.c index d95ffdb..db82589 100644 --- a/gnu/lib/libdialog/prgbox.c +++ b/gnu/lib/libdialog/prgbox.c @@ -43,6 +43,11 @@ int dialog_prgbox(unsigned char *title, const char *line, int height, int width, draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c index 3618e68..5a21518 100644 --- a/gnu/lib/libdialog/radiolist.c +++ b/gnu/lib/libdialog/radiolist.c @@ -67,6 +67,11 @@ int dialog_radiolist(char *title, char *prompt, int height, int width, int list_ draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); @@ -99,6 +104,11 @@ int dialog_radiolist(char *title, char *prompt, int height, int width, int list_ /* create new window for the list */ list = subwin(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1); + if (list == NULL) { + endwin(); + fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", list_height,list_width,y+box_y+1,x+box_x+1); + exit(1); + } keypad(list, TRUE); /* draw a box around the list items */ diff --git a/gnu/lib/libdialog/textbox.c b/gnu/lib/libdialog/textbox.c index cb87474..670ea49 100644 --- a/gnu/lib/libdialog/textbox.c +++ b/gnu/lib/libdialog/textbox.c @@ -92,11 +92,21 @@ int dialog_textbox(unsigned char *title, unsigned char *file, int height, int wi draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); /* Create window for text region, used for scrolling text */ /* text = newwin(height-4, width-2, y+1, x+1); */ text = subwin(dialog, height-4, width-2, y+1, x+1); + if (text == NULL) { + endwin(); + fprintf(stderr, "\nsubwin(dialog,%d,%d,%d,%d) failed, maybe wrong dims\n", height-4,width-2,y+1,x+1); + exit(1); + } keypad(text, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); diff --git a/gnu/lib/libdialog/yesno.c b/gnu/lib/libdialog/yesno.c index c97d800..3f21b5a 100644 --- a/gnu/lib/libdialog/yesno.c +++ b/gnu/lib/libdialog/yesno.c @@ -40,6 +40,11 @@ int dialog_yesno(unsigned char *title, unsigned char * prompt, int height, int w draw_shadow(stdscr, y, x, height, width); #endif dialog = newwin(height, width, y, x); + if (dialog == NULL) { + endwin(); + fprintf(stderr, "\nnewwin(%d,%d,%d,%d) failed, maybe wrong dims\n", height,width,y,x); + exit(1); + } keypad(dialog, TRUE); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); |