about summary refs log tree commit diff
path: root/Src/Zle/compmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/compmatch.c')
-rw-r--r--Src/Zle/compmatch.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 05ae43ae6..b5728a5fe 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -338,8 +338,15 @@ add_match_str(Cmatcher m, char *l, char *w, int wl, int sfx)
 	    char *buf;
 
 	    buf = (char *) zalloc(blen);
-	    memcpy(buf, matchbuf, matchbuflen);
-	    zfree(matchbuf, matchbuflen);
+	    if (matchbuf) {
+		memcpy(buf, matchbuf, matchbuflen);
+		zfree(matchbuf, matchbuflen);
+	    }
+#ifdef DEBUG
+	    else {
+		DPUTS(matchbuflen, "matchbuflen with no matchbuf");
+	    }
+#endif
 	    matchbuf = buf;
 	    matchbuflen = blen;
 	}