Skip to content

Commit 150d268

Browse files
committed
strdup env_location
1 parent f7b4abd commit 150d268

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

main/php_ini.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,27 +432,27 @@ static char* get_env_location(const char *envname)
432432
size = GetEnvironmentVariableA(envname, &dummybuf, 0);
433433
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
434434
/* The environment variable doesn't exist. */
435-
return "";
435+
return NULL;
436436
}
437437

438438
if (size == 0) {
439-
return "";
439+
return NULL;
440440
}
441441

442442
size = GetEnvironmentVariableA(envname, phprc_path, size);
443443
if (size == 0) {
444-
return "";
444+
return NULL;
445445
}
446446

447447
env_location = phprc_path;
448448
}
449449
#else
450450
if (!env_location) {
451-
return "";
451+
return NULL;
452452
}
453453
#endif
454454

455-
return env_location;
455+
return estrdup(env_location);
456456
}
457457
/* }}} */
458458

@@ -520,6 +520,10 @@ int php_init_config(void)
520520
php_ini_file_name = env_location;
521521
}
522522

523+
if (env_location) {
524+
efree(env_location);
525+
}
526+
523527
#ifdef PHP_WIN32
524528
/* Add registry location */
525529
reg_location = GetIniPathFromRegistry();

0 commit comments

Comments
 (0)