mshtml: Fixed a leak (valgrind).
authorJacek Caban <jacek@codeweavers.com>
Tue, 15 Feb 2011 16:33:27 +0000 (17:33 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 15 Feb 2011 16:42:26 +0000 (17:42 +0100)
dlls/mshtml/protocol.c

index 58f4deec1ea091fb83606b2cd66340dcd1c34dcc..dad93ba2b1c6efa168f4f560c70c66db649d7d6e 100644 (file)
@@ -217,6 +217,8 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
     BINDINFO bindinfo;
     DWORD grfBINDF = 0;
     LPCWSTR text = NULL;
+    DWORD data_len;
+    BYTE *data;
 
     static const WCHAR html_begin[] = {0xfeff,'<','H','T','M','L','>',0};
     static const WCHAR html_end[] = {'<','/','H','T','M','L','>',0};
@@ -247,9 +249,15 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
             text = NULL;
     }
 
-    This->data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR) 
+    data_len = sizeof(html_begin)+sizeof(html_end)-sizeof(WCHAR)
         + (text ? strlenW(text)*sizeof(WCHAR) : 0);
-    This->data = heap_alloc(This->data_len);
+    data = heap_alloc(data_len);
+    if(!data)
+        return E_OUTOFMEMORY;
+
+    heap_free(This->data);
+    This->data = data;
+    This->data_len = data_len;
 
     memcpy(This->data, html_begin, sizeof(html_begin));
     if(text)