about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/parameter.c6
-rw-r--r--Src/Zle/zle_misc.c12
-rw-r--r--Src/subst.c2
3 files changed, 10 insertions, 10 deletions
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));