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

Re: PATCH: zle status line



Andrey Borzenkov wrote:
> e-n-c passes constant prmt that unmetafy is trying to assign to. It is too 
> late for me to decide whether all callers of stringaslinezle or it itself 
> should provide a writable copy of instr.

Oops, it should be the caller and it's even documented.  I hope there
aren't other cases I've missed.  There's also a typo that only
gets triggered on completion in execute-named-command owing to lazy
symbol resolution.

Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.19
diff -u -r1.19 zle_misc.c
--- Src/Zle/zle_misc.c	24 Feb 2005 15:32:57 -0000	1.19
+++ Src/Zle/zle_misc.c	24 Feb 2005 21:07:09 -0000
@@ -775,10 +775,13 @@
     char *okeymap = ztrdup(curkeymapname);
 
     clearlist = 1;
+    /* prmt may be constant */
+    prmt = ztrdup(prmt);
     zprmt = stringaszleline((unsigned char *)prmt, &l, NULL);
     cmdbuf = zhalloc((l + NAMLEN + 2) * ZLE_CHAR_SIZE);
     ZS_memcpy(cmdbuf, zprmt, l);
     free(zprmt);
+    zsfree(prmt);
     statusline = cmdbuf;
     selectkeymap("main", 1);
     ptr = cmdbuf += l;
@@ -919,7 +922,7 @@
 		    int ltmp;
 		    ZLE_STRING_T ztmp = stringaszleline(peekfirst(cmdll),
 							&ltmp, NULL);
-		    ZS_mempcy(cmdbuf, ztmp, ltmp);
+		    ZS_memcpy(cmdbuf, ztmp, ltmp);
 		    free(ztmp);
 		    ptr = cmdbuf + cmdambig;
 		    *ptr = ZWC('_');


-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



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