From: Tom Hughes Date: Mon, 18 Jul 2005 23:23:03 +0000 (+0000) Subject: Fix crash when no environment is given to execve. X-Git-Tag: svn/VALGRIND_3_0_0~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a1ea2d7cc5644bf4841531fff31bfda374ccfa2;p=thirdparty%2Fvalgrind.git Fix crash when no environment is given to execve. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4169 --- diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index c86691dee8..8d72deb32f 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -2280,7 +2280,7 @@ void VG_(reap_threads)(ThreadId self) PRE(sys_execve) { Char* path; /* path to executable */ - Char** envp; + Char** envp = NULL; ThreadState* tst; PRINT("sys_execve ( %p(%s), %p, %p )", ARG1, ARG1, ARG2, ARG3); @@ -2333,8 +2333,8 @@ PRE(sys_execve) // stage1/2 will set up the appropriate client environment. // Nb: we make a copy of the environment before trying to mangle it // as it might be in read-only memory (this was bug #101881). - envp = VG_(env_clone)( (Char**)ARG3 ); - if (envp != NULL) { + if (ARG3 != NULL) { + envp = VG_(env_clone)( (Char**)ARG3 ); VG_(env_remove_valgrind_env_stuff)( envp ); }