msvcrt: Fix a possible memory leak in _wpopen if a memory allocation fails.

This commit is contained in:
Andrew Nguyen 2011-01-15 02:28:08 -06:00 committed by Alexandre Julliard
parent 587a9aa9f0
commit 9361b61949
1 changed files with 6 additions and 1 deletions

View File

@ -1079,7 +1079,12 @@ MSVCRT_FILE* CDECL MSVCRT__wpopen(const MSVCRT_wchar_t* command, const MSVCRT_wc
if (!(comspec = msvcrt_get_comspec())) goto error;
len = strlenW(comspec) + strlenW(flag) + strlenW(command) + 1;
if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) goto error;
if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t))))
{
HeapFree(GetProcessHeap(), 0, comspec);
goto error;
}
strcpyW(fullcmd, comspec);
strcatW(fullcmd, flag);
strcatW(fullcmd, command);