Hi there,
I've been fixing my implementation of resize for my game and noticed that if you call wresize with a window that doesn't fit within SP->lines and SP->cols it doesn't return ERR. This was a problem for me because my program would call wtouchwin immediately after and segfault.
I took a look at newwin and it has protection against this case, but wresize does not.
|
if (!SP || begy + nlines > SP->lines || begx + ncols > SP->cols) |
|
return (WINDOW *)NULL; |
For my program I wrote a dumb little wrapper around wresize that performs the check:
int
wresize_wrapper(WINDOW *win, int nlines, int ncols) noexcept
{
// THIS WAS COPIED FROM newwin
if (!SP || win->_begy + nlines > SP->lines || win->_begx + ncols > SP->cols)
return ERR;
return ::wresize(win, nlines, ncols);
}
- Do you agree that not having this check is a problem?
- Would you be open to having this fixed?
Thank you so much for your time.
Hi there,
I've been fixing my implementation of resize for my game and noticed that if you call
wresizewith a window that doesn't fit withinSP->linesandSP->colsit doesn't return ERR. This was a problem for me because my program would callwtouchwinimmediately after and segfault.I took a look at
newwinand it has protection against this case, butwresizedoes not.PDCurses/pdcurses/window.c
Lines 276 to 277 in 5c62af0
For my program I wrote a dumb little wrapper around wresize that performs the check:
Thank you so much for your time.