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

Re: [PATCH] allocate origline by ztrdup(), not by dupstring()



2015/06/17 01:54, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:

> This part is run when pressing backspace, it seems to always be the case
> that origline == u->origline before this block runs. So it is copying freed
> memory.

Backspace (in the interactive mode) seems to work as expected with the
following patch. Does this look reasonable?


diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 0f73181..ccee9a7 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2655,7 +2655,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    s->nbrbeg = nbrbeg;
 	    s->nbrend = nbrend;
 	    s->nmatches = nmatches;
-	    s->origline = origline;
+	    s->origline = dupstring(origline);
 	    s->origcs = origcs;
 	    s->origll = origll;
             s->status = dupstring(status);
@@ -2786,7 +2786,7 @@ domenuselect(Hookdef dummy, Chdata dat)
 	    s->nbrbeg = nbrbeg;
 	    s->nbrend = nbrend;
 	    s->nmatches = nmatches;
-	    s->origline = origline;
+	    s->origline = dupstring(origline);
 	    s->origcs = origcs;
 	    s->origll = origll;
             s->status = dupstring(status);





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