[PATCH] windowscodecs: do not leak profile on errors (Coverity)

Marcus Meissner marcus at jet.franken.de
Fri Mar 15 14:09:14 CDT 2013


free *profile on all error exits from load_profile()

CID 981944

Ciao, Marcus
---
 dlls/windowscodecs/colorcontext.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/colorcontext.c b/dlls/windowscodecs/colorcontext.c
index ca40184..268b6ef 100644
--- a/dlls/windowscodecs/colorcontext.c
+++ b/dlls/windowscodecs/colorcontext.c
@@ -126,8 +126,16 @@ static HRESULT load_profile(const WCHAR *filename, BYTE **profile, UINT *len)
     }
     ret = ReadFile(handle, *profile, size.u.LowPart, &count, NULL);
     CloseHandle(handle);
-    if (!ret) return HRESULT_FROM_WIN32(GetLastError());
-    if (count != size.u.LowPart) return E_FAIL;
+    if (!ret) {
+        HeapFree (GetProcessHeap(),0,*profile);
+        *profile = NULL;
+        return HRESULT_FROM_WIN32(GetLastError());
+    }
+    if (count != size.u.LowPart) {
+        HeapFree (GetProcessHeap(),0,*profile);
+        *profile = NULL;
+        return E_FAIL;
+    }
     *len = count;
     return S_OK;
 }
-- 
1.7.10.4




More information about the wine-patches mailing list