summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-08-28 08:41:51 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-08-28 08:41:51 +0000
commitc0ea4d62c81f7480192b1f61649f82d064dcb716 (patch)
tree3ff9b3deb6c3c95aa536ef59db564e73f97f4b9b
parent7806ece93122c27478d74d53518c75500c3a5749 (diff)
downloadzsh-c0ea4d62c81f7480192b1f61649f82d064dcb716.tar.gz
zsh-c0ea4d62c81f7480192b1f61649f82d064dcb716.tar.xz
zsh-c0ea4d62c81f7480192b1f61649f82d064dcb716.zip
handle possible NULL pointer returned from bufferwords() (15717)
-rw-r--r--ChangeLog6
-rw-r--r--Src/Modules/parameter.c6
-rw-r--r--Src/Zle/zle_misc.c12
-rw-r--r--Src/subst.c2
4 files changed, 16 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e146396d..6097f9093 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-28  Sven Wischnowsky  <wischnow@zsh.org>
+
+	* 15717: Src/subst.c, Src/Modules/parameter.c,
+	Src/Zle/zle_misc.c: handle possible NULL pointer returned from
+	bufferwords()
+
 2001-08-27  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* 15713: Completion/Redhat/Command/_rpm: added package-specification
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index fe44eafb3..23c868598 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -1105,9 +1105,9 @@ histwgetfn(Param pm)
     int i = addhistnum(curhist, -1, HIST_FOREIGN), iw;
     Histent he = gethistent(i, GETHIST_UPWARD);
 
-    ll = bufferwords(NULL, NULL, NULL);
-    for (n = firstnode(ll); n; incnode(n))
-	pushnode(l, getdata(n));
+    if ((ll = bufferwords(NULL, NULL, NULL)))
+        for (n = firstnode(ll); n; incnode(n))
+            pushnode(l, getdata(n));
 
     while (he) {
 	for (iw = he->nwords - 1; iw >= 0; iw--) {
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 2a650af86..e24d0c08b 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -549,13 +549,13 @@ copyprevshellword(char **args)
     int i;
     char *p = NULL;
 
-    l = bufferwords(NULL, NULL, &i);
+    if ((l = bufferwords(NULL, NULL, &i)))
+        for (n = firstnode(l); n; incnode(n))
+            if (!i--) {
+                p = getdata(n);
+                break;
+            }
 
-    for (n = firstnode(l); n; incnode(n))
-	if (!i--) {
-	    p = getdata(n);
-	    break;
-	}
     if (p) {
 	int len = strlen(p);
 
diff --git a/Src/subst.c b/Src/subst.c
index 0ef084106..8bd1a1ae3 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1833,7 +1833,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	} else
 	    list = bufferwords(NULL, val, NULL);
 
-	if (!firstnode(list))
+	if (!list || !firstnode(list))
 	    val = dupstring("");
 	else if (!nextnode(firstnode(list)))
 	    val = getdata(firstnode(list));