Make sure that windows are not off the left or top edges of the screen.

Noticed while looking at PR 21041.
This commit is contained in:
jdc 2003-04-08 05:56:01 +00:00
parent 119cd94332
commit 38b99f1400
2 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mvwin.c,v 1.13 2002/01/02 10:38:28 blymn Exp $ */
/* $NetBSD: mvwin.c,v 1.14 2003/04/08 05:56:01 jdc Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: mvwin.c,v 1.13 2002/01/02 10:38:28 blymn Exp $");
__RCSID("$NetBSD: mvwin.c,v 1.14 2003/04/08 05:56:01 jdc Exp $");
#endif
#endif /* not lint */
@ -79,7 +79,7 @@ mvwin(WINDOW *win, int by, int bx)
WINDOW *orig;
int dy, dx;
if (by + win->maxy > LINES || bx + win->maxx > COLS)
if (by < 0 || by + win->maxy > LINES || bx < 0 || bx + win->maxx > COLS)
return (ERR);
dy = by - win->begy;
dx = bx - win->begx;

View File

@ -1,4 +1,4 @@
/* $NetBSD: newwin.c,v 1.34 2003/02/17 11:07:20 dsl Exp $ */
/* $NetBSD: newwin.c,v 1.35 2003/04/08 05:56:01 jdc Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94";
#else
__RCSID("$NetBSD: newwin.c,v 1.34 2003/02/17 11:07:20 dsl Exp $");
__RCSID("$NetBSD: newwin.c,v 1.35 2003/04/08 05:56:01 jdc Exp $");
#endif
#endif /* not lint */
@ -132,6 +132,9 @@ __newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad)
int maxy, maxx;
__LDATA *sp;
if (by < 0 || bx < 0)
return (NULL);
maxy = nlines > 0 ? nlines : LINES - by + nlines;
maxx = ncols > 0 ? ncols : COLS - bx + ncols;