From 96f4984f9fb76a0546b71e3018e441224fe747ed Mon Sep 17 00:00:00 2001 From: Bill-Gray Date: Sun, 4 Oct 2020 13:27:14 -0400 Subject: [PATCH] Added assert()s on a lot of NULL parameters. In theory, you should be able to call most functions in Curses with NULLs and just get an error code back. But if you do so, it will almost invariably indicate a bug that ought to result in bombing out so you'll know about it and fix it. Such cases should not be harmlessly elided, resulting in crashes later on that leave you scratching your head. --- pdcurses/addch.c | 2 ++ pdcurses/addchstr.c | 3 +++ pdcurses/addstr.c | 5 +++++ pdcurses/attr.c | 9 +++++++++ pdcurses/beep.c | 1 + pdcurses/bkgd.c | 6 ++++++ pdcurses/border.c | 6 ++++++ pdcurses/clear.c | 4 ++++ pdcurses/delch.c | 2 ++ pdcurses/deleteln.c | 4 ++++ pdcurses/getyx.c | 9 +++++++++ pdcurses/inch.c | 6 ++++++ pdcurses/inchstr.c | 3 +++ pdcurses/instr.c | 7 +++++++ pdcurses/kernel.c | 1 + pdcurses/mouse.c | 5 +++++ pdcurses/outopts.c | 4 ++++ pdcurses/overlay.c | 7 +++++++ pdcurses/pad.c | 5 +++++ pdcurses/panel.c | 16 ++++++++++++++++ pdcurses/refresh.c | 4 ++++ pdcurses/scroll.c | 2 ++ pdcurses/termattr.c | 3 +++ pdcurses/touch.c | 9 +++++++++ pdcurses/util.c | 15 +++++++++++++++ 25 files changed, 138 insertions(+) diff --git a/pdcurses/addch.c b/pdcurses/addch.c index 120a51e3..f738ea9e 100644 --- a/pdcurses/addch.c +++ b/pdcurses/addch.c @@ -645,6 +645,7 @@ int wadd_wch(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch)); + assert( wch); return wch ? waddch(win, *wch) : ERR; } @@ -687,6 +688,7 @@ int wecho_wchar(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch)); + assert( wch); if (!wch || (wadd_wch(win, wch) == ERR)) return ERR; diff --git a/pdcurses/addchstr.c b/pdcurses/addchstr.c index 10fc2794..9f2f7642 100644 --- a/pdcurses/addchstr.c +++ b/pdcurses/addchstr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -74,6 +75,8 @@ int waddchnstr(WINDOW *win, const chtype *ch, int n) PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n)); + assert( win); + assert( ch); if (!win || !ch || !n || n < -1) return ERR; diff --git a/pdcurses/addstr.c b/pdcurses/addstr.c index a7d85396..9d746afd 100644 --- a/pdcurses/addstr.c +++ b/pdcurses/addstr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -69,6 +70,8 @@ int waddnstr(WINDOW *win, const char *str, int n) PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n)); + assert( win); + assert( str); if (!win || !str) return ERR; @@ -162,6 +165,8 @@ int waddnwstr(WINDOW *win, const wchar_t *wstr, int n) PDC_LOG(("waddnwstr() - called\n")); + assert( win); + assert( wstr); if (!win || !wstr) return ERR; diff --git a/pdcurses/attr.c b/pdcurses/attr.c index 020f1482..8420ded4 100644 --- a/pdcurses/attr.c +++ b/pdcurses/attr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -133,6 +134,7 @@ int wattroff(WINDOW *win, chtype attrs) { PDC_LOG(("wattroff() - called\n")); + assert( win); if (!win) return ERR; @@ -154,6 +156,7 @@ int wattron(WINDOW *win, chtype attrs) PDC_LOG(("wattron() - called\n")); + assert( win); if (!win) return ERR; @@ -183,6 +186,7 @@ int wattrset(WINDOW *win, chtype attrs) { PDC_LOG(("wattrset() - called\n")); + assert( win); if (!win) return ERR; @@ -228,6 +232,7 @@ int wstandout(WINDOW *win) chtype getattrs(WINDOW *win) { + assert( win); return win ? win->_attrs : 0; } @@ -235,6 +240,7 @@ int wcolor_set(WINDOW *win, short color_pair, void *opts) { PDC_LOG(("wcolor_set() - called\n")); + assert( win); if (!win) return ERR; @@ -254,6 +260,7 @@ int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts) { PDC_LOG(("wattr_get() - called\n")); + assert( win); if (!win) return ERR; @@ -305,6 +312,7 @@ int wattr_set(WINDOW *win, attr_t attrs, short color_pair, void *opts) { PDC_LOG(("wattr_set() - called\n")); + assert( win); if (!win) return ERR; @@ -327,6 +335,7 @@ int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts) PDC_LOG(("wchgat() - called\n")); + assert( win); if (!win) return ERR; diff --git a/pdcurses/beep.c b/pdcurses/beep.c index 85845dec..21b138ad 100644 --- a/pdcurses/beep.c +++ b/pdcurses/beep.c @@ -55,6 +55,7 @@ int flash(void) PDC_LOG(("flash() - called\n")); + assert( curscr); if (!curscr) return ERR; diff --git a/pdcurses/bkgd.c b/pdcurses/bkgd.c index f5764373..0806dce6 100644 --- a/pdcurses/bkgd.c +++ b/pdcurses/bkgd.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -72,6 +73,7 @@ int wbkgd(WINDOW *win, chtype ch) PDC_LOG(("wbkgd() - called\n")); + assert( win); if (!win) return ERR; @@ -172,6 +174,7 @@ chtype getbkgd(WINDOW *win) { PDC_LOG(("getbkgd() - called\n")); + assert( win); return win ? win->_bkgd : (chtype)ERR; } @@ -180,6 +183,7 @@ int wbkgrnd(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wbkgrnd() - called\n")); + assert( wch); return wch ? wbkgd(win, *wch) : ERR; } @@ -209,6 +213,8 @@ int wgetbkgrnd(WINDOW *win, cchar_t *wch) { PDC_LOG(("wgetbkgrnd() - called\n")); + assert( win); + assert( wch); if (!win || !wch) return ERR; diff --git a/pdcurses/border.c b/pdcurses/border.c index 62458b68..b234b783 100644 --- a/pdcurses/border.c +++ b/pdcurses/border.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -141,6 +142,7 @@ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, PDC_LOG(("wborder() - called\n")); + assert( win); if (!win) return ERR; @@ -206,6 +208,7 @@ int whline(WINDOW *win, chtype ch, int n) PDC_LOG(("whline() - called\n")); + assert( win); if (!win || n < 1) return ERR; @@ -263,6 +266,7 @@ int wvline(WINDOW *win, chtype ch, int n) PDC_LOG(("wvline() - called\n")); + assert( win); if (!win || n < 1) return ERR; @@ -348,6 +352,7 @@ int whline_set(WINDOW *win, const cchar_t *wch, int n) { PDC_LOG(("whline_set() - called\n")); + assert( wch); return wch ? whline(win, *wch, n) : ERR; } @@ -382,6 +387,7 @@ int wvline_set(WINDOW *win, const cchar_t *wch, int n) { PDC_LOG(("wvline_set() - called\n")); + assert( wch); return wch ? wvline(win, *wch, n) : ERR; } diff --git a/pdcurses/clear.c b/pdcurses/clear.c index 50ff7ad3..9b6ccae7 100644 --- a/pdcurses/clear.c +++ b/pdcurses/clear.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -58,6 +59,7 @@ int wclrtoeol(WINDOW *win) PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n", win->_cury, win->_curx)); + assert( win); if (!win) return ERR; @@ -93,6 +95,7 @@ int wclrtobot(WINDOW *win) PDC_LOG(("wclrtobot() - called\n")); + assert( win); if (!win) return ERR; @@ -144,6 +147,7 @@ int wclear(WINDOW *win) { PDC_LOG(("wclear() - called\n")); + assert( win); if (!win) return ERR; diff --git a/pdcurses/delch.c b/pdcurses/delch.c index 970a5a81..3f9219c6 100644 --- a/pdcurses/delch.c +++ b/pdcurses/delch.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -44,6 +45,7 @@ int wdelch(WINDOW *win) PDC_LOG(("wdelch() - called\n")); + assert( win); if (!win) return ERR; diff --git a/pdcurses/deleteln.c b/pdcurses/deleteln.c index 8e7563f3..68072bca 100644 --- a/pdcurses/deleteln.c +++ b/pdcurses/deleteln.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -60,6 +61,7 @@ int wdeleteln(WINDOW *win) PDC_LOG(("wdeleteln() - called\n")); + assert( win); if (!win) return ERR; @@ -122,6 +124,7 @@ int winsdelln(WINDOW *win, int n) PDC_LOG(("winsdelln() - called\n")); + assert( win); if (!win) return ERR; @@ -156,6 +159,7 @@ int winsertln(WINDOW *win) PDC_LOG(("winsertln() - called\n")); + assert( win); if (!win) return ERR; diff --git a/pdcurses/getyx.c b/pdcurses/getyx.c index 9400076e..0f9b7c8c 100644 --- a/pdcurses/getyx.c +++ b/pdcurses/getyx.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -76,6 +77,7 @@ int getbegy(WINDOW *win) { PDC_LOG(("getbegy() - called\n")); + assert( win); return win ? win->_begy : ERR; } @@ -83,6 +85,7 @@ int getbegx(WINDOW *win) { PDC_LOG(("getbegx() - called\n")); + assert( win); return win ? win->_begx : ERR; } @@ -90,6 +93,7 @@ int getcury(WINDOW *win) { PDC_LOG(("getcury() - called\n")); + assert( win); return win ? win->_cury : ERR; } @@ -97,6 +101,7 @@ int getcurx(WINDOW *win) { PDC_LOG(("getcurx() - called\n")); + assert( win); return win ? win->_curx : ERR; } @@ -104,6 +109,7 @@ int getpary(WINDOW *win) { PDC_LOG(("getpary() - called\n")); + assert( win); return win ? win->_pary : ERR; } @@ -111,6 +117,7 @@ int getparx(WINDOW *win) { PDC_LOG(("getparx() - called\n")); + assert( win); return win ? win->_parx : ERR; } @@ -118,6 +125,7 @@ int getmaxy(WINDOW *win) { PDC_LOG(("getmaxy() - called\n")); + assert( win); return win ? win->_maxy : ERR; } @@ -125,6 +133,7 @@ int getmaxx(WINDOW *win) { PDC_LOG(("getmaxx() - called\n")); + assert( win); return win ? win->_maxx : ERR; } diff --git a/pdcurses/inch.c b/pdcurses/inch.c index e3275a8c..c5293bcd 100644 --- a/pdcurses/inch.c +++ b/pdcurses/inch.c @@ -1,5 +1,6 @@ /* PDCurses */ +#include #include /*man-start************************************************************** @@ -47,6 +48,7 @@ chtype winch(WINDOW *win) { PDC_LOG(("winch() - called\n")); + assert( win); if (!win) return (chtype)ERR; @@ -85,6 +87,8 @@ int win_wch(WINDOW *win, cchar_t *wcval) { PDC_LOG(("win_wch() - called\n")); + assert( win); + assert( wcval); if (!win || !wcval) return ERR; @@ -104,6 +108,7 @@ int mvin_wch(int y, int x, cchar_t *wcval) { PDC_LOG(("mvin_wch() - called\n")); + assert( wcval); if (!wcval || (move(y, x) == ERR)) return ERR; @@ -116,6 +121,7 @@ int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval) { PDC_LOG(("mvwin_wch() - called\n")); + assert( wcval); if (!wcval || (wmove(win, y, x) == ERR)) return ERR; diff --git a/pdcurses/inchstr.c b/pdcurses/inchstr.c index 97a00831..67185395 100644 --- a/pdcurses/inchstr.c +++ b/pdcurses/inchstr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -65,6 +66,8 @@ int winchnstr(WINDOW *win, chtype *ch, int n) PDC_LOG(("winchnstr() - called\n")); + assert( win); + assert( ch); if (!win || !ch || n < 0) return ERR; diff --git a/pdcurses/instr.c b/pdcurses/instr.c index 718d2ae3..42194a9a 100644 --- a/pdcurses/instr.c +++ b/pdcurses/instr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -67,6 +68,8 @@ int winnstr(WINDOW *win, char *str, int n) #ifdef PDC_WIDE wchar_t wstr[513]; + assert( win); + assert( str); if (n < 0 || n > 512) n = 512; @@ -78,6 +81,8 @@ int winnstr(WINDOW *win, char *str, int n) chtype *src; int i; + assert( win); + assert( str); PDC_LOG(("winnstr() - called: n %d \n", n)); if (!win || !str) @@ -166,6 +171,8 @@ int winnwstr(WINDOW *win, wchar_t *wstr, int n) PDC_LOG(("winnstr() - called: n %d \n", n)); + assert( win); + assert( wstr); if (!win || !wstr) return ERR; diff --git a/pdcurses/kernel.c b/pdcurses/kernel.c index bb1d0bd4..e396fb94 100644 --- a/pdcurses/kernel.c +++ b/pdcurses/kernel.c @@ -268,6 +268,7 @@ int ripoffline(int line, int (*init)(WINDOW *, int)) { PDC_LOG(("ripoffline() - called: line=%d\n", line)); + assert( init); if (linesrippedoff < 5 && line && init) { linesripped[(int)linesrippedoff].line = line; diff --git a/pdcurses/mouse.c b/pdcurses/mouse.c index f14feff7..c09d8438 100644 --- a/pdcurses/mouse.c +++ b/pdcurses/mouse.c @@ -241,6 +241,7 @@ bool wenclose(const WINDOW *win, int y, int x) { PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x)); + assert( win); return (win && y >= win->_begy && y < win->_begy + win->_maxy && x >= win->_begx && x < win->_begx + win->_maxx); } @@ -251,6 +252,9 @@ bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen) PDC_LOG(("wmouse_trafo() - called\n")); + assert( win); + assert( x); + assert( y); if (!win || !y || !x) return FALSE; @@ -388,6 +392,7 @@ int ungetmouse(MEVENT *event) PDC_LOG(("ungetmouse() - called\n")); + assert( event); if (!event || ungot) return ERR; diff --git a/pdcurses/outopts.c b/pdcurses/outopts.c index 37d3de97..d3c1b972 100644 --- a/pdcurses/outopts.c +++ b/pdcurses/outopts.c @@ -76,6 +76,7 @@ int clearok(WINDOW *win, bool bf) { PDC_LOG(("clearok() - called\n")); + assert( win); if (!win) return ERR; @@ -108,6 +109,7 @@ int leaveok(WINDOW *win, bool bf) { PDC_LOG(("leaveok() - called\n")); + assert( win); if (!win) return ERR; @@ -129,6 +131,7 @@ int wsetscrreg(WINDOW *win, int top, int bottom) { PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom)); + assert( win); if (win && 0 <= top && top <= win->_cury && win->_cury <= bottom && bottom < win->_maxy) { @@ -145,6 +148,7 @@ int scrollok(WINDOW *win, bool bf) { PDC_LOG(("scrollok() - called\n")); + assert( win); if (!win) return ERR; diff --git a/pdcurses/overlay.c b/pdcurses/overlay.c index 5bcc6274..670802f7 100644 --- a/pdcurses/overlay.c +++ b/pdcurses/overlay.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -60,6 +61,8 @@ static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int xdiff = src_bc - src_tc; int ydiff = src_br - src_tr; + assert( src_w); + assert( dst_w); if (!src_w || !dst_w) return ERR; @@ -122,6 +125,8 @@ int _copy_overlap(const WINDOW *src_w, WINDOW *dst_w, bool overlay) int src_start_x, src_start_y, dst_start_x, dst_start_y; int xdiff, ydiff; + assert( src_w); + assert( dst_w); if (!src_w || !dst_w) return ERR; @@ -194,6 +199,8 @@ int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc, PDC_LOG(("copywin() - called\n")); + assert( src_w); + assert( dst_w); if (!src_w || !dst_w || dst_w == curscr || dst_br >= dst_w->_maxy || dst_bc >= dst_w->_maxx || dst_tr < 0 || dst_tc < 0) return ERR; diff --git a/pdcurses/pad.c b/pdcurses/pad.c index 0b1d6147..53efc8bf 100644 --- a/pdcurses/pad.c +++ b/pdcurses/pad.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -118,6 +119,7 @@ WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx) PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n", nlines, ncols, begy, begx)); + assert( orig); if (!orig || !(orig->_flags & _PAD)) return (WINDOW *)NULL; @@ -184,6 +186,7 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) PDC_LOG(("pnoutrefresh() - called\n")); + assert( w); if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sx2 >= COLS)) return ERR; @@ -259,6 +262,7 @@ int pecho_wchar(WINDOW *pad, const cchar_t *wch) { PDC_LOG(("pecho_wchar() - called\n")); + assert( wch); if (!wch || (waddch(pad, *wch) == ERR)) return ERR; @@ -271,6 +275,7 @@ bool is_pad(const WINDOW *pad) { PDC_LOG(("is_pad() - called\n")); + assert( pad); if (!pad) return FALSE; diff --git a/pdcurses/panel.c b/pdcurses/panel.c index 50618407..bee7d14c 100644 --- a/pdcurses/panel.c +++ b/pdcurses/panel.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -198,6 +199,8 @@ static void Touchline(PANEL *pan, int start, int count) static bool _panels_overlapped(PANEL *pan1, PANEL *pan2) { + assert( pan1); + assert( pan2); if (!pan1 || !pan2) return FALSE; @@ -412,6 +415,7 @@ static void _panel_unlink(PANEL *pan) int bottom_panel(PANEL *pan) { + assert( pan); if (!pan) return ERR; @@ -428,6 +432,7 @@ int bottom_panel(PANEL *pan) int del_panel(PANEL *pan) { + assert( pan); if (pan) { if (_panel_is_linked(pan)) @@ -442,6 +447,7 @@ int del_panel(PANEL *pan) int hide_panel(PANEL *pan) { + assert( pan); if (!pan) return ERR; @@ -462,6 +468,7 @@ int move_panel(PANEL *pan, int starty, int startx) WINDOW *win; int maxy, maxx, rval; + assert( pan); if (!pan) return ERR; @@ -489,6 +496,7 @@ PANEL *new_panel(WINDOW *win) { PANEL *pan; + assert( win); if (!win) return (PANEL *)NULL; @@ -550,6 +558,7 @@ PANEL *ground_panel( SCREEN *sp) int panel_hidden(const PANEL *pan) { + assert( pan); if (!pan) return ERR; @@ -558,6 +567,7 @@ int panel_hidden(const PANEL *pan) const void *panel_userptr(const PANEL *pan) { + assert( pan); return pan ? pan->user : NULL; } @@ -565,6 +575,7 @@ WINDOW *panel_window(const PANEL *pan) { PDC_LOG(("panel_window() - called\n")); + assert( pan); if (!pan) return (WINDOW *)NULL; @@ -575,6 +586,8 @@ int replace_panel(PANEL *pan, WINDOW *win) { int maxy, maxx; + assert( pan); + assert( win); if (!pan) return ERR; @@ -595,6 +608,7 @@ int replace_panel(PANEL *pan, WINDOW *win) int set_panel_userptr(PANEL *pan, const void *uptr) { + assert( pan); if (!pan) return ERR; @@ -604,6 +618,7 @@ int set_panel_userptr(PANEL *pan, const void *uptr) int show_panel(PANEL *pan) { + assert( pan); if (!pan) return ERR; @@ -620,6 +635,7 @@ int show_panel(PANEL *pan) int top_panel(PANEL *pan) { + assert( pan); return show_panel(pan); } diff --git a/pdcurses/refresh.c b/pdcurses/refresh.c index ff7d127b..9531abce 100644 --- a/pdcurses/refresh.c +++ b/pdcurses/refresh.c @@ -77,6 +77,7 @@ int wnoutrefresh(WINDOW *win) PDC_LOG(("wnoutrefresh() - called: win=%p\n", win)); + assert( win); if ( !win || (win->_flags & (_PAD|_SUBPAD)) ) return ERR; @@ -247,6 +248,7 @@ int wrefresh(WINDOW *win) PDC_LOG(("wrefresh() - called\n")); + assert( win); if ( !win || (win->_flags & (_PAD|_SUBPAD)) ) return ERR; @@ -277,6 +279,7 @@ int wredrawln(WINDOW *win, int start, int num) PDC_LOG(("wredrawln() - called: win=%p start=%d num=%d\n", win, start, num)); + assert( win); if (!win || start > win->_maxy || start + num > win->_maxy) return ERR; @@ -293,6 +296,7 @@ int redrawwin(WINDOW *win) { PDC_LOG(("redrawwin() - called: win=%p\n", win)); + assert( win); if (!win) return ERR; diff --git a/pdcurses/scroll.c b/pdcurses/scroll.c index ffe8d0d9..87b07dcd 100644 --- a/pdcurses/scroll.c +++ b/pdcurses/scroll.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -45,6 +46,7 @@ int wscrl(WINDOW *win, int n) /* Check if window scrolls. Valid for window AND pad */ + assert( win); if (!win || !win->_scroll || !n) return ERR; diff --git a/pdcurses/termattr.c b/pdcurses/termattr.c index 37c84a43..20e7ae53 100644 --- a/pdcurses/termattr.c +++ b/pdcurses/termattr.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -151,6 +152,7 @@ int erasewchar(wchar_t *ch) { PDC_LOG(("erasewchar() - called\n")); + assert( ch); if (!ch) return ERR; @@ -163,6 +165,7 @@ int killwchar(wchar_t *ch) { PDC_LOG(("killwchar() - called\n")); + assert( ch); if (!ch) return ERR; diff --git a/pdcurses/touch.c b/pdcurses/touch.c index e1b7c60e..56cfa605 100644 --- a/pdcurses/touch.c +++ b/pdcurses/touch.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -66,6 +67,7 @@ int touchwin(WINDOW *win) PDC_LOG(("touchwin() - called: Win=%x\n", win)); + assert( win); if (!win) return ERR; @@ -85,6 +87,7 @@ int touchline(WINDOW *win, int start, int count) PDC_LOG(("touchline() - called: win=%p start %d count %d\n", win, start, count)); + assert( win); if (!win || start > win->_maxy || start + count > win->_maxy) return ERR; @@ -103,6 +106,7 @@ int untouchwin(WINDOW *win) PDC_LOG(("untouchwin() - called: win=%p", win)); + assert( win); if (!win) return ERR; @@ -122,6 +126,7 @@ int wtouchln(WINDOW *win, int y, int n, int changed) PDC_LOG(("wtouchln() - called: win=%p y=%d n=%d changed=%d\n", win, y, n, changed)); + assert( win); if (!win || y > win->_maxy || y + n > win->_maxy) return ERR; @@ -146,6 +151,7 @@ bool is_linetouched(WINDOW *win, int line) { PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line)); + assert( win); if (!win || line > win->_maxy || line < 0) return FALSE; @@ -158,6 +164,7 @@ bool is_wintouched(WINDOW *win) PDC_LOG(("is_wintouched() - called: win=%p\n", win)); + assert( win); if (win) for (i = 0; i < win->_maxy; i++) if (win->_firstch[i] != _NO_CHANGE) @@ -172,6 +179,8 @@ int touchoverlap(const WINDOW *win1, WINDOW *win2) PDC_LOG(("touchoverlap() - called: win1=%p win2=%p\n", win1, win2)); + assert( win1); + assert( win2); if (!win1 || !win2) return ERR; diff --git a/pdcurses/util.c b/pdcurses/util.c index c7d1bc26..c222e2d9 100644 --- a/pdcurses/util.c +++ b/pdcurses/util.c @@ -1,6 +1,7 @@ /* PDCurses */ #include +#include /*man-start************************************************************** @@ -165,11 +166,14 @@ int PDC_wc_to_utf8( char *dest, const int32_t code) int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts) { + assert( wcval); if (!wcval) return ERR; if (wch) { + assert( attrs); + assert( color_pair); if (!attrs || !color_pair) return ERR; @@ -189,6 +193,8 @@ int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs, short color_pair, const void *opts) { + assert( wcval); + assert( wch); if (!wcval || !wch) return ERR; @@ -205,6 +211,7 @@ wchar_t *wunctrl(cchar_t *wc) PDC_LOG(("wunctrl() - called\n")); + assert( wc); if (!wc) return NULL; @@ -236,6 +243,8 @@ int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n) int i = -1; const unsigned char *string; + assert( s); + assert( pwc); if (!s || (n < 1)) return -1; @@ -279,6 +288,8 @@ int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n) return i; # else + assert( s); + assert( pwc); return mbtowc(pwc, s, n); # endif } @@ -288,6 +299,8 @@ size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n) # ifdef PDC_FORCE_UTF8 size_t i = 0, len; + assert( src); + assert( dest); if (!src || !dest) return 0; @@ -316,6 +329,8 @@ size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n) # ifdef PDC_FORCE_UTF8 size_t i = 0; + assert( src); + assert( dest); if (!src || !dest) return 0;