[PATCH v3 2/9] winedbg: Free buffer and return NULL if size==0 in packet_realloc().

Jinoh Kang jinoh.kang.kr at gmail.com
Tue Nov 16 10:51:07 CST 2021


packet_realloc() does not return on error, so we can use NULL for normal
circumstances.

Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---
 programs/winedbg/gdbproxy.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index deb6b0973f5..3f5584633e4 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -707,6 +707,12 @@ enum packet_return {packet_error = 0x00, packet_ok = 0x01, packet_done = 0x02,
 
 static char* packet_realloc(char* buf, int size)
 {
+    if (!size)
+    {
+        if (buf)
+            HeapFree(GetProcessHeap(), 0, buf);
+        return NULL;
+    }
     if (!buf)
         return HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, size);
     return HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, buf, size);
-- 
2.31.1




More information about the wine-devel mailing list