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

Re: Valgrind warning from vared -c



(I was not able to follow workers these days, and am now trying
 to catch up with it...slowly)

> 2023/02/26 7:31, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 
> Doesn't happen on vared of an existing param, as far as I can tell.
> 
> ==1443300== Conditional jump or move depends on uninitialised value(s)
> ==1443300==    at 0x2612D1: zleread (zle_main.c:1353)
> ==1443300==    by 0x263333: bin_vared (zle_main.c:1833)
(snip)
>   1353     if (zleline && *zleline)
>   1354         redrawhook();

It seems *zleline is not set correctly when zleline is empty.
Please try the following:


diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 454a877a9..51bb43339 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -512,12 +512,13 @@ stringaszleline(char *instr, int incs, int *outll, int *outsz, int *outcs)
 	    *outcs = outptr - outstr;
 	*outll = outptr - outstr;
     } else {
+	*outstr = ZWC('\0');
 	*outll = 0;
 	if (outcs)
 	    *outcs = 0;
     }
 #else
-    memcpy(outstr, instr, ll);
+    strcpy(outstr, instr);
     *outll = ll;
     if (outcs)
 	*outcs = incs;







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