Skip to content

Commit

Permalink
Added assert()s to check various input parameters to core functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-Gray committed Oct 3, 2024
1 parent d2f479a commit 027c3a5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions pdcurses/insch.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ int winsch(WINDOW *win, chtype ch)
x = win->_curx;
y = win->_cury;

assert( y <= win->_maxy && x <= win->_maxx && y >= 0 && x >= 0);
if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
return ERR;

Expand Down
6 changes: 6 additions & 0 deletions pdcurses/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ void PDC_set_changed_cells_range( WINDOW *win, const int y, const int start, con
{
assert( win);
assert( y >= 0 && y < win->_maxy);
assert( start >= 0 || start == _NO_CHANGE);
assert( start <= end);
assert( end < win->_maxx);
win->_firstch[y] = start;
win->_lastch[y] = end;
}
Expand All @@ -81,6 +84,9 @@ void PDC_mark_cells_as_changed( WINDOW *win, const int y, const int start, const
{
assert( win);
assert( y >= 0 && y < win->_maxy);
assert( start >= 0 || start == _NO_CHANGE);
assert( start <= end);
assert( end < win->_maxx);
if( win->_firstch[y] == _NO_CHANGE)
{
win->_firstch[y] = start;
Expand Down
2 changes: 2 additions & 0 deletions pdcurses/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ WINDOW *PDC_makelines(WINDOW *win)
assert( win);
if (!win)
return (WINDOW *)NULL;
assert( win->_maxy > 0);
assert( win->_maxx > 0);

nlines = win->_maxy;
ncols = win->_maxx;
Expand Down

0 comments on commit 027c3a5

Please sign in to comment.