user.exe16: Fix memory leak in case when HeapReAlloc fails.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2017-06-22 15:56:24 +08:00 committed by Alexandre Julliard
parent f7fd2c2be1
commit 8c3ed82927
1 changed files with 4 additions and 1 deletions

View File

@ -3245,8 +3245,11 @@ DWORD WINAPI FormatMessage16(
/* CMF - This makes a BIG assumption about va_list */
while ((ret = vsnprintf(b, sz, fmtstr, (va_list) argliststart)) < 0 || ret >= sz) {
LPSTR new_b;
sz = (ret == -1 ? sz + 100 : ret + 1);
b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz);
new_b = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, b, sz);
if (!new_b) break;
b = new_b;
}
for (x=b; *x; x++) ADD_TO_T(*x);
HeapFree(GetProcessHeap(), 0, b);