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

Re: handling of variables



[moved to -workers]

On Feb 1,  4:40pm, Bart Schaefer wrote:
} 
} I now think that exec.c:save_params() needs to copy the value returned
} by ecrawstr() before storing it in the restore_p linked list

That should say "remove_p" not "restore_p".

} but I'm not sure what kind of memory to copy it into

Got a chance to look at this again; addlinknode() uses the heap, so it
should be safe to dupstring() here.

And the following does indeed fix the problem.

Index: Src/exec.c
===================================================================
diff -c -r1.23 exec.c
--- Src/exec.c	13 Jan 2005 04:12:14 -0000	1.23
+++ Src/exec.c	2 Feb 2005 03:41:43 -0000
@@ -2554,10 +2554,10 @@
 		copyparam(tpm, pm, 1);
 		pm = tpm;
 	    }
-	    addlinknode(*remove_p, s);
+	    addlinknode(*remove_p, dupstring(s));
 	    addlinknode(*restore_p, pm);
 	} else
-	    addlinknode(*remove_p, s);
+	    addlinknode(*remove_p, dupstring(s));
 
 	pc += (WC_ASSIGN_TYPE(ac) == WC_ASSIGN_SCALAR ?
 	       3 : WC_ASSIGN_NUM(ac) + 2);



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