Dmitry Timoshkov : user.exe16: Fix memory leak in case when HeapReAlloc fails.
Alexandre Julliard
julliard at winehq.org
Thu Jun 22 16:50:51 CDT 2017
Module: wine
Branch: master
Commit: 8c3ed829279cb7951688392801e3210abd19d27f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8c3ed829279cb7951688392801e3210abd19d27f
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Thu Jun 22 15:56:24 2017 +0800
user.exe16: Fix memory leak in case when HeapReAlloc fails.
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user.exe16/user.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index aba797d..4a00d58 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -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);
More information about the wine-cvs
mailing list