Skip to content

wresize doesn't return ERR if the window size requested is too big #162

Description

@bjadamson

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.

PDCurses/pdcurses/window.c

Lines 276 to 277 in 5c62af0

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);
}
  1. Do you agree that not having this check is a problem?
  2. Would you be open to having this fixed?
    Thank you so much for your time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions