Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses * Size argument for memset when clearing cbuf ...



details:   https://anonhg.NetBSD.org/src/rev/506b8221b1d3
branches:  trunk
changeset: 779936:506b8221b1d3
user:      blymn <blymn%NetBSD.org@localhost>
date:      Fri Jun 29 10:40:29 2012 +0000

description:
* Size argument for memset when clearing cbuf was wrong, cbuf is an array
  of char not int so memset was stomping memory past the end of the array.
  Use sizeof properly to correctly determine the amount of memory to clear.

diffstat:

 lib/libcurses/get_wch.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 4eea051bdb3d -r 506b8221b1d3 lib/libcurses/get_wch.c
--- a/lib/libcurses/get_wch.c   Thu Jun 28 18:55:03 2012 +0000
+++ b/lib/libcurses/get_wch.c   Fri Jun 29 10:40:29 2012 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wch.c,v 1.9 2010/12/16 17:42:28 wiz Exp $ */
+/*   $NetBSD: get_wch.c,v 1.10 2012/06/29 10:40:29 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: get_wch.c,v 1.9 2010/12/16 17:42:28 wiz Exp $");
+__RCSID("$NetBSD: get_wch.c,v 1.10 2012/06/29 10:40:29 blymn Exp $");
 #endif                                           /* not lint */
 
 #include <string.h>
@@ -67,7 +67,7 @@
 __init_get_wch(SCREEN *screen)
 {
        wstate = INKEY_NORM;
-       memset( &screen->cbuf, 0, MAX_CBUF_SIZE * sizeof( int ));
+       memset( &screen->cbuf, 0, sizeof(screen->cbuf));
        screen->cbuf_head = screen->cbuf_tail = screen->cbuf_cur = 0;
 }
 #endif /* HAVE_WCHAR */



Home | Main Index | Thread Index | Old Index