zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] allocate origline by ztrdup(), not by dupstring()
@ 2015-01-06 16:37 Jun T.
  2015-01-06 18:23 ` Jun T.
  2015-06-16 16:54 ` Oliver Kiddle
  0 siblings, 2 replies; 6+ messages in thread
From: Jun T. @ 2015-01-06 16:37 UTC (permalink / raw)
  To: zsh-workers

Currently, domenuselect() allocates origline in heap by dupstring(),
but if menuselect() is called directly as a widget then the heap has
already been freed (and may have been re-used for other variables).
---
 Src/Zle/complist.c   | 6 ++++--
 Src/Zle/zle_tricky.c | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index b6e7e30..8850506 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2882,7 +2882,8 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    brend = dupbrinfo(u->brend, &lastbrend, 0);
 	    nbrbeg = u->nbrbeg;
 	    nbrend = u->nbrend;
-	    origline = u->origline;
+	    zsfree(origline);
+	    origline = ztrdup(u->origline);
 	    origcs = u->origcs;
 	    origll = u->origll;
             strcpy(status, u->status);
@@ -3236,7 +3237,8 @@ domenuselect(Hookdef dummy, Chdata dat)
 		 * don't want that, just what the user typed,
 		 * so restore the information.
 		 */
-                origline = modeline;
+		zsfree(origline);
+		origline = ztrdup(modeline);
                 origcs = modecs;
                 origll = modell;
                 zlemetacs = 0;
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 864f804..950c22f 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -634,7 +634,8 @@ docomplete(int lst)
     metafy_line();
 
     ocs = zlemetacs;
-    origline = dupstring(zlemetaline);
+    zsfree(origline);
+    origline = ztrdup(zlemetaline);
     origcs = zlemetacs;
     origll = zlemetall;
     if (!isfirstln && (chline != NULL || zle_chline != NULL)) {
-- 
1.9.3 (Apple Git-50)



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-22  8:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 16:37 [PATCH] allocate origline by ztrdup(), not by dupstring() Jun T.
2015-01-06 18:23 ` Jun T.
2015-06-16 16:54 ` Oliver Kiddle
2015-06-17 16:24   ` Jun T.
2015-06-21 11:53   ` Jun T.
2015-06-22  8:36     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).