urlmon: Avoid memory leaks (coverity)

André Hentschel nerv at dawncrow.de
Sun Oct 28 10:17:03 CDT 2012


CID 713724 & 713726 & 713727
---
 dlls/urlmon/bindprot.c | 3 +++
 dlls/urlmon/uri.c      | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/urlmon/bindprot.c b/dlls/urlmon/bindprot.c
index 60912a4..8deccda 100644
--- a/dlls/urlmon/bindprot.c
+++ b/dlls/urlmon/bindprot.c
@@ -1149,7 +1149,10 @@ static HRESULT WINAPI BPInternetProtocolSink_Switch(IInternetProtocolSink *iface
 
         task = heap_alloc(sizeof(switch_task_t));
         if(!task)
+        {
+            heap_free(data);
             return E_OUTOFMEMORY;
+        }
 
         task->data = data;
 
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 20e0582..18e2ebb 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -5185,8 +5185,10 @@ static HRESULT WINAPI PersistStream_Load(IPersistStream *iface, IStream *pStm)
     if(!data)
         return E_OUTOFMEMORY;
     hr = IStream_Read(pStm, &data->unk1, size-sizeof(DWORD)-2, NULL);
-    if(FAILED(hr))
+    if(FAILED(hr)) {
+        heap_free(data);
         return hr;
+    }
 
     if(size < sizeof(struct persist_uri)) {
         heap_free(data);
@@ -6356,8 +6358,10 @@ HRESULT WINAPI CreateIUriBuilder(IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserve
         Uri *uri;
 
         if((uri = get_uri_obj(pIUri))) {
-            if(!uri->create_flags)
+            if(!uri->create_flags) {
+                heap_free(ret);
                 return E_UNEXPECTED;
+            }
             IUri_AddRef(pIUri);
             ret->uri = uri;
 
-- 
1.8.0


-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list