OSDN Git Service

Make toy_init() reentrant, or else xexec() has funky errors.
authorRob Landley <rob@landley.net>
Wed, 6 Jan 2010 11:29:17 +0000 (05:29 -0600)
committerRob Landley <rob@landley.net>
Wed, 6 Jan 2010 11:29:17 +0000 (05:29 -0600)
main.c

diff --git a/main.c b/main.c
index e0dab1c..4b4b376 100644 (file)
--- a/main.c
+++ b/main.c
@@ -76,10 +76,12 @@ void toy_init(struct toy_list *which, char *argv[])
 
                if ((which->flags & TOYFLAG_NEEDROOT) && euid)
                        error_exit("Not root");
-
        }
 
-       // Free old toys contents here?
+       // Free old toys contents (to be reentrant)
+
+       if (toys.optargs != toys.argv+1) free(toys.optargs);
+       bzero(&toys, sizeof(struct toy_context));
 
        toys.which = which;
        toys.argv = argv;