Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Two issues found with -fsanitize=undefined



On Thu, 17 Sep 2015 09:57:59 +0200
Markus Trippelsdorf <markus@xxxxxxxxxxxxxxx> wrote:
> 2)
>  compmatch.c:341:6: runtime error: null pointer passed as argument 2, which is declared to never be null}
> Test ./Y02compmatch.ztst failed: output differs from expected as shown above for:

This might be benign, if the final argument is also zero; this should
tell us.

pws

diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index 05ae43a..b5728a5 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;
 	}



Messages sorted by: Reverse Date, Date, Thread, Author