Module Name: src
Committed By: christos
Date: Mon Jan 9 02:54:18 UTC 2017
Modified Files:
src/lib/libedit: chartype.c
Log Message:
Make sure that argv is NULL terminated since functions like tty_stty rely
on it to be so (Gerry Swinslow)
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libedit/chartype.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/chartype.c
diff -u src/lib/libedit/chartype.c:1.30 src/lib/libedit/chartype.c:1.31
--- src/lib/libedit/chartype.c:1.30 Mon May 9 17:46:56 2016
+++ src/lib/libedit/chartype.c Sun Jan 8 21:54:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.30 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $");
#endif /* not lint && not SCCSID */
#include <ctype.h>
@@ -156,7 +156,7 @@ ct_decode_argv(int argc, const char *arg
if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
return NULL;
- wargv = el_malloc((size_t)argc * sizeof(*wargv));
+ wargv = el_malloc((size_t)(argc + 1) * sizeof(*wargv));
for (i = 0, p = conv->wbuff; i < argc; ++i) {
if (!argv[i]) { /* don't pass null pointers to mbstowcs */
@@ -174,6 +174,7 @@ ct_decode_argv(int argc, const char *arg
bufspace -= (size_t)bytes;
p += bytes;
}
+ wargv[i] = NULL;
return wargv;
}