Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Change the test for the size of encoded buffer t...



details:   https://anonhg.NetBSD.org/src/rev/2345e690c36d
branches:  trunk
changeset: 343578:2345e690c36d
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Feb 15 15:30:50 2016 +0000

description:
Change the test for the size of encoded buffer to include the NULL, from
OpenBSD; no functional change.

diffstat:

 lib/libedit/history.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 48a454f58e29 -r 2345e690c36d lib/libedit/history.c
--- a/lib/libedit/history.c     Mon Feb 15 15:29:25 2016 +0000
+++ b/lib/libedit/history.c     Mon Feb 15 15:30:50 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: history.c,v 1.48 2016/02/15 15:26:48 christos Exp $    */
+/*     $NetBSD: history.c,v 1.49 2016/02/15 15:30:50 christos Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)history.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: history.c,v 1.48 2016/02/15 15:26:48 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.49 2016/02/15 15:30:50 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -806,8 +806,8 @@
            retval != -1;
            retval = HPREV(h, &ev), i++) {
                str = ct_encode_string(ev.str, &conv);
-               len = strlen(str) * 4;
-               if (len >= max_size) {
+               len = strlen(str) * 4 + 1;
+               if (len > max_size) {
                        char *nptr;
                        max_size = (len + 1024) & (size_t)~1023;
                        nptr = h_realloc(ptr, max_size * sizeof(*ptr));



Home | Main Index | Thread Index | Old Index