Skip to content

Commit

Permalink
Check for binary_location allocation failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebbyastian authored and krakjoe committed Nov 22, 2017
1 parent 269d160 commit 7e0feb8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,17 @@ static void php_disable_classes(void)
*/
static void php_binary_init(void)
{
char *binary_location;
char *binary_location = NULL;
#ifdef PHP_WIN32
binary_location = (char *)malloc(MAXPATHLEN);
if (GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) {
if (binary_location && GetModuleFileName(0, binary_location, MAXPATHLEN) == 0) {
free(binary_location);
PG(php_binary) = NULL;
}
#else
if (sapi_module.executable_location) {
binary_location = (char *)malloc(MAXPATHLEN);
if (!strchr(sapi_module.executable_location, '/')) {
if (binary_location && !strchr(sapi_module.executable_location, '/')) {
char *envpath, *path;
int found = 0;

Expand Down Expand Up @@ -299,8 +299,6 @@ static void php_binary_init(void)
free(binary_location);
binary_location = NULL;
}
} else {
binary_location = NULL;
}
#endif
PG(php_binary) = binary_location;
Expand Down

0 comments on commit 7e0feb8

Please sign in to comment.