Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Always NULL terminate the argv[] array. From Ope...



details:   https://anonhg.NetBSD.org/src/rev/9d6a2aaaec5e
branches:  trunk
changeset: 796102:9d6a2aaaec5e
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 20 15:05:08 2014 +0000

description:
Always NULL terminate the argv[] array. From OpenBSD.

diffstat:

 lib/libedit/eln.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 3a42fd4f0f96 -r 9d6a2aaaec5e lib/libedit/eln.c
--- a/lib/libedit/eln.c Tue May 20 14:23:43 2014 +0000
+++ b/lib/libedit/eln.c Tue May 20 15:05:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.15 2014/02/26 13:50:29 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.16 2014/05/20 15:05:08 christos Exp $        */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.15 2014/02/26 13:50:29 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.16 2014/05/20 15:05:08 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -158,10 +158,10 @@
                const char *argv[20];
                int i;
                const wchar_t **wargv;
-               for (i = 1; i < (int)__arraycount(argv); ++i)
-                       if ((argv[i] = va_arg(ap, char *)) == NULL)
+               for (i = 1; i < (int)__arraycount(argv) - 1; ++i)
+                       if ((argv[i] = va_arg(ap, const char *)) == NULL)
                            break;
-               argv[0] = NULL;
+               argv[0] = argv[i] = NULL;
                wargv = (const wchar_t **)
                    ct_decode_argv(i + 1, argv, &el->el_lgcyconv);
                if (!wargv) {



Home | Main Index | Thread Index | Old Index