1
0
Fork 0

fixed some invalid free I introduced when running binaries without command line arguments

This commit is contained in:
Jan Steemann 2012-08-09 19:26:25 +02:00
parent 43b7ea951a
commit 25c8555135
1 changed files with 11 additions and 2 deletions

View File

@ -153,6 +153,12 @@ static bool IsEnvironmentEnlarged = false;
static size_t MaximalProcessTitleSize = 0;
////////////////////////////////////////////////////////////////////////////////
/// @brief do we need to free the copy of the environ data on shutdown
////////////////////////////////////////////////////////////////////////////////
static bool MustFreeEnvironment = false;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
@ -343,6 +349,7 @@ void TRI_SetProcessTitle (char const* title) {
newEnviron[i] = NULL;
environ = newEnviron;
MustFreeEnvironment = true;
}
IsEnvironmentEnlarged = true;
@ -395,10 +402,12 @@ void TRI_InitialiseProcess (int argc, char* argv[]) {
void TRI_ShutdownProcess () {
TRI_FreeString(TRI_CORE_MEM_ZONE, ProcessName);
if (environ) {
// free all arguments copied for environ
if (MustFreeEnvironment) {
size_t i = 0;
assert(environ);
// free all arguments copied for environ
while (environ[i]) {
TRI_FreeString(TRI_CORE_MEM_ZONE, environ[i]);
++i;