about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/compmatch.c11
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1dd57123c..4a8c0531a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-21  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 36580: Src/Zle/compmatch.c: don't copy empty buffer and check
+	size is consistent.
+
 2015-09-21  Frank Terbeck  <ft@bewatermyfriend.org>
 
 	* 36575: Completion/Unix/Command/_tmux: _tmux: ‘lock-server’
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;
 	}