Module Name:    src
Committed By:   christos
Date:           Thu Feb 14 20:09:12 UTC 2019

Modified Files:
        src/lib/libedit: readline.c

Log Message:
PR/53981: Jonathan Perkins: history_list should null-terminate


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/lib/libedit/readline.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/readline.c
diff -u src/lib/libedit/readline.c:1.149 src/lib/libedit/readline.c:1.150
--- src/lib/libedit/readline.c:1.149	Thu Jan 10 13:41:56 2019
+++ src/lib/libedit/readline.c	Thu Feb 14 15:09:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.c,v 1.149 2019/01/10 18:41:56 christos Exp $	*/
+/*	$NetBSD: readline.c,v 1.150 2019/02/14 20:09:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.149 2019/01/10 18:41:56 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.150 2019/02/14 20:09:12 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -1590,7 +1590,7 @@ history_list(void)
 		return NULL;
 
 	if ((nlp = el_realloc(_history_listp,
-	    (size_t)history_length * sizeof(*nlp))) == NULL)
+	    ((size_t)history_length + 1) * sizeof(*nlp))) == NULL)
 		return NULL;
 	_history_listp = nlp;
 
@@ -1607,6 +1607,7 @@ history_list(void)
 		if (i++ == history_length)
 			abort();
 	} while (history(h, &ev, H_PREV) == 0);
+	_history_listp[i] = NULL;
 	return _history_listp;
 }
 

Reply via email to