com php-src: add error check and fix leak: ext/standard/proc_ open.c
| From: | Anatol Belski | Date: | Mon, 29 Aug 2016 15:25:46 +0000 |
| Subject: | com php-src: add error check and fix leak: ext/standard/proc_ open.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94110@lists.php.net to get a copy of this message | ||
Commit: 201f90a8ccd5d4578f3200781341dc3b781c36f2
Author: Anatol Belski <ab@php.net> Mon, 29 Aug 2016 17:25:46 +0200
Parents: 7ecfb4b95447b2da3ff1fbef3a3b2a9eacd38a63
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=201f90a8ccd5d4578f3200781341dc3b781c36f2
Log:
add error check and fix leak
Changed paths:
M ext/standard/proc_open.c
Diff:
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index e443ec6..95803c9 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -753,9 +753,14 @@ PHP_FUNCTION(proc_open)
len = (sizeof(COMSPEC_NT) + sizeof(" /c ") + tmp_len + 1);
cmdw2 = (wchar_t *)malloc(len * sizeof(wchar_t));
+ if (!cmdw2) {
+ php_error_docref(NULL, E_WARNING, "Command conversion failed");
+ goto exit_fail;
+ }
ret = _snwprintf(cmdw2, len, L"%hs /c %s", COMSPEC_NT, cmdw);
if (-1 == ret) {
+ free(cmdw2);
php_error_docref(NULL, E_WARNING, "Command conversion failed");
goto exit_fail;
}