Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses PR bin/57072



details:   https://anonhg.NetBSD.org/src/rev/cdb3f5c42c4e
branches:  trunk
changeset: 372247:cdb3f5c42c4e
user:      blymn <blymn%NetBSD.org@localhost>
date:      Fri Nov 04 06:12:22 2022 +0000

description:
PR bin/57072

This fixes observed behviour in the PR.  Allow the cursor to be
moved one past the EOL, if postitioned here then set ISPASTEOL.
also protect out of range access if win->cury is past maxy.

diffstat:

 lib/libcurses/move.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 7c7284160f87 -r cdb3f5c42c4e lib/libcurses/move.c
--- a/lib/libcurses/move.c      Thu Nov 03 18:55:07 2022 +0000
+++ b/lib/libcurses/move.c      Fri Nov 04 06:12:22 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $  */
+/*     $NetBSD: move.c,v 1.25 2022/11/04 06:12:22 blymn Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c     8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $");
+__RCSID("$NetBSD: move.c,v 1.25 2022/11/04 06:12:22 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -65,13 +65,17 @@
        __CTRACE(__CTRACE_MISC, "wmove: win %p, (%d, %d)\n", win, y, x);
        if (x < 0 || y < 0)
                return ERR;
-       if (x >= win->maxx || y >= win->maxy)
+       if (x > win->maxx || y >= win->maxy)
                return ERR;
 
        /* clear the EOL flags for both where we were and where we are going */
-       win->alines[win->cury]->flags &= ~ __ISPASTEOL;
+       if (win->cury < win->maxy)
+               win->alines[win->cury]->flags &= ~ __ISPASTEOL;
        win->alines[y]->flags &= ~ __ISPASTEOL;
 
+       if (x == win->maxx)
+               win->alines[y]->flags |= __ISPASTEOL;
+
        win->curx = x;
        win->cury = y;
 



Home | Main Index | Thread Index | Old Index