Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Make sure that windows are not off the left or...



details:   https://anonhg.NetBSD.org/src/rev/a96c9daafb69
branches:  trunk
changeset: 545397:a96c9daafb69
user:      jdc <jdc%NetBSD.org@localhost>
date:      Tue Apr 08 05:56:01 2003 +0000

description:
Make sure that windows are not off the left or top edges of the screen.
Noticed while looking at PR 21041.

diffstat:

 lib/libcurses/mvwin.c  |  6 +++---
 lib/libcurses/newwin.c |  7 +++++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 69f62d1a8105 -r a96c9daafb69 lib/libcurses/mvwin.c
--- a/lib/libcurses/mvwin.c     Tue Apr 08 05:53:49 2003 +0000
+++ b/lib/libcurses/mvwin.c     Tue Apr 08 05:56:01 2003 +0000
@@ -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 @@
        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;
diff -r 69f62d1a8105 -r a96c9daafb69 lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c    Tue Apr 08 05:53:49 2003 +0000
+++ b/lib/libcurses/newwin.c    Tue Apr 08 05:56:01 2003 +0000
@@ -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 @@
        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;
 



Home | Main Index | Thread Index | Old Index