diff options
| author | christos <christos@NetBSD.org> | 2017-01-09 02:54:18 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2017-01-09 02:54:18 +0000 |
| commit | 4ef2962ad87cc8fd9cf34ff80b0eece8cc636d95 (patch) | |
| tree | 561dcb23a1c7c5b667568fdfb9dfe0fd5e3e28de /lib/libedit | |
| parent | 9a6fddcabaaeecb105b1eb0d472485be828dc2d7 (diff) | |
Make sure that argv is NULL terminated since functions like tty_stty rely
on it to be so (Gerry Swinslow)
Diffstat (limited to 'lib/libedit')
| -rw-r--r-- | lib/libedit/chartype.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c index f350dfd2ded..9288e6b7db2 100644 --- a/lib/libedit/chartype.c +++ b/lib/libedit/chartype.c @@ -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 *argv[], ct_buffer_t *conv) 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 *argv[], ct_buffer_t *conv) bufspace -= (size_t)bytes; p += bytes; } + wargv[i] = NULL; return wargv; } |
