Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Fix initial line hash calculation for subwindows



details:   https://anonhg.NetBSD.org/src/rev/d50d11b09b82
branches:  trunk
changeset: 983658:d50d11b09b82
user:      mcf <mcf%NetBSD.org@localhost>
date:      Tue Jun 01 00:59:01 2021 +0000

description:
Fix initial line hash calculation for subwindows

lp->hash is not initialized at this point. Since the hash is
calculated in chunks using __hash_more(), it needs to be initialized
to 0 first (just as in doupdate()).

Detected with valgrind while running python's test suite when
debugging an unrelated issue.

ok uwe@

diffstat:

 lib/libcurses/newwin.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 0829ddefa86c -r d50d11b09b82 lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c    Tue Jun 01 00:30:22 2021 +0000
+++ b/lib/libcurses/newwin.c    Tue Jun 01 00:59:01 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $  */
+/*     $NetBSD: newwin.c,v 1.60 2021/06/01 00:59:01 mcf Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)newwin.c   8.3 (Berkeley) 7/27/94";
 #else
-__RCSID("$NetBSD: newwin.c,v 1.59 2021/05/15 11:06:07 uwe Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.60 2021/06/01 00:59:01 mcf Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -252,6 +252,7 @@
                lp->hash = __hash((char *)(void *)lp->line,
                                  (size_t)(win->maxx * __LDATASIZE));
 #else
+               lp->hash = 0;
                for (cp = lp->line, j = 0; j < win->maxx; j++, cp++) {
                        lp->hash = __hash_more( &cp->ch,
                            sizeof( wchar_t ), lp->hash );



Home | Main Index | Thread Index | Old Index