setupapi: fix memory leak (found by Smatch)

Lionel_Debroux lionel_debroux at yahoo.fr
Fri Aug 31 07:20:26 CDT 2007


SetupQueryInfFileInformationA leaks some heap memory in three error
paths. Found in Michael Stefaniuc's list of Wine potential bugs detected
by Smatch.


2007-08-31  Lionel Debroux <lionel_debroux at yahoo.fr>
       * dlls/setupapi/query.c:
       setupapi: fix memory leak (found by Smatch)

-------------- next part --------------
>From bb070c7dcf9f62d0ec034db2e84d93d27758a120 Mon Sep 17 00:00:00 2001
From: Lionel Debroux <lionel_debroux at yahoo.fr>
Date: Fri, 31 Aug 2007 14:16:56 +0200
Subject: setupapi: fix memory leak (found by Smatch).

---
 dlls/setupapi/query.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c
index 04b9c4d..e9190d5 100644
--- a/dlls/setupapi/query.c
+++ b/dlls/setupapi/query.c
@@ -243,15 +243,18 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
     {
         if (ReturnBufferSize)
         {
+            HeapFree(GetProcessHeap(), 0, filenameW);
             SetLastError(ERROR_INVALID_PARAMETER);
             return FALSE;
         }
 
+        HeapFree(GetProcessHeap(), 0, filenameW);
         return TRUE;
     }
 
     if (size > ReturnBufferSize)
     {
+        HeapFree(GetProcessHeap(), 0, filenameW);
         SetLastError(ERROR_INSUFFICIENT_BUFFER);
         return FALSE;
     }
-- 
1.4.4.4



More information about the wine-patches mailing list