Right now using toybox's version of cd from toysh with no argument gives me
a segfault, apparently from freeing an invalid pointer in run_pipeline().
The attached patch fixes it for me.

Felix
# HG changeset patch
# User Felix Janda <[email protected]>
# Date 1356864807 -3600
# Node ID 5106e537d59662ebb9d4d95ac462d8949b56541d
# Parent  cf7bbafa06d1533b650d93f18cbdead47297286e
Fix invalid free in toysh.

diff -r cf7bbafa06d1 -r 5106e537d596 toys/posix/sh.c
--- a/toys/posix/sh.c	Fri Dec 28 22:10:21 2012 +0100
+++ b/toys/posix/sh.c	Sun Dec 30 11:53:27 2012 +0100
@@ -305,7 +305,7 @@
       tl->toy_main();
     }
     cmd->pid = toys.exitval;
-    free(toys.optargs);
+    if (toys.optargs != toys.argv+1) free(toys.optargs);
     if (toys.old_umask) umask(toys.old_umask);
     memcpy(&toys, &temp, sizeof(struct toy_context));
   } else {
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to