From db037ef6e0d7e84e5fd9ba831b55550a9b487257 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 6 Jan 2010 05:29:17 -0600 Subject: Make toy_init() reentrant, or else xexec() has funky errors. --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index e0dab1cc..4b4b3765 100644 --- 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; -- cgit v1.2.3