com php-src: Check for binary_location allocation failure : main/main.c
| From: | Joe Watkins | Date: | Wed, 22 Nov 2017 04:49:04 +0000 |
| Subject: | com php-src: Check for binary_location allocation failure : main/main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100342@lists.php.net to get a copy of this message | ||
Commit: 7e0feb88562c2488240664e1f6ab42f42dae3cb6
Author: Sebastian Ramadan <plebbyastian@gmail.com> Wed, 15 Nov 2017 13:24:28 +1100
Committer: krakjoe <krakjoe@php.net> Wed, 22 Nov 2017 04:49:04 +0000
Parents: 269d1601596341f574ff6c875a826ce2b671f1f0
Branches: PHP-7.0 PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7e0feb88562c2488240664e1f6ab42f42dae3cb6
Log:
Check for binary_location allocation failure
Changed paths:
M main/main.c
Diff:
diff --git a/main/main.c b/main/main.c
index ce33cfb..93ac6ca 100644
--- a/main/main.c
+++ b/main/main.c
@@ -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;
@@ -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;