From 7ecfb4b95447b2da3ff1fbef3a3b2a9eacd38a63 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 29 Aug 2016 17:25:13 +0200 Subject: [PATCH 1/2] fix leak --- win32/ioutil.c | 1 + 1 file changed, 1 insertion(+) diff --git a/win32/ioutil.c b/win32/ioutil.c index c57cff18746..b01edd241d4 100644 --- a/win32/ioutil.c +++ b/win32/ioutil.c @@ -425,6 +425,7 @@ PW32IO wchar_t *php_win32_ioutil_getcwd_w(const wchar_t *buf, int len) if (!GetCurrentDirectoryW(len, buf)) { err = GetLastError(); SET_ERRNO_FROM_WIN32_CODE(err); + free(tmp_buf); return NULL; } From 201f90a8ccd5d4578f3200781341dc3b781c36f2 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 29 Aug 2016 17:25:46 +0200 Subject: [PATCH 2/2] add error check and fix leak --- ext/standard/proc_open.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index e443ec64a65..95803c9bbd4 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; }