diff options
author | Martin Schlemmer <azarah@gentoo.org> | 2006-07-08 23:24:31 +0000 |
---|---|---|
committer | Martin Schlemmer <azarah@gentoo.org> | 2006-07-08 23:24:31 +0000 |
commit | 678a48f8c6210f0cda2bcefbd62e8114fcdec791 (patch) | |
tree | ae580e425227811bce946b5d77de97f1182b69cf | |
parent | Free child environ we allocated earlier, as at execve() duplicates (diff) | |
download | sandbox-678a48f8c6210f0cda2bcefbd62e8114fcdec791.tar.gz sandbox-678a48f8c6210f0cda2bcefbd62e8114fcdec791.tar.bz2 sandbox-678a48f8c6210f0cda2bcefbd62e8114fcdec791.zip |
Free child argv we allocated earlier, as at execve() duplicates
this, so no need to keep it around and waiste more memory. Make
sure we will not in future free them twice.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
-rw-r--r-- | src/sandbox.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sandbox.c b/src/sandbox.c index 4b3e87f..de68610 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -546,6 +546,7 @@ int spawn_shell(char *argv_bash[], char **env, int debug) /* execve() creates a copy of this, so no need to use more memory than * absolutely needed. */ + str_list_free(argv_bash); str_list_free(env); ret = waitpid(child_pid, &status, 0); @@ -674,8 +675,11 @@ int main(int argc, char **argv) if (!spawn_shell(argv_bash, sandbox_environ, print_debug)) success = 0; - /* Free bash argv stuff */ - str_list_free(argv_bash); + /* As spawn_shell() free both argv_bash and sandbox_environ, make sure + * we do not run into issues in future if we need a OOM error below + * this ... */ + argv_bash = NULL; + sandbox_environ = NULL; if (print_debug) printf("Cleaning up sandbox process\n"); |