=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: mshtml: Avoid memory leaks ( Coverity).

Alexandre Julliard julliard at winehq.org
Mon Dec 2 13:37:52 CST 2013


Module: wine
Branch: master
Commit: 60a592b77a2f0c5339a68cfc3d0da3105b1c81c1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=60a592b77a2f0c5339a68cfc3d0da3105b1c81c1

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Sat Nov 30 20:17:31 2013 +0100

mshtml: Avoid memory leaks (Coverity).

---

 dlls/mshtml/htmlbody.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c
index fcd8766..6c2bb7a 100644
--- a/dlls/mshtml/htmlbody.c
+++ b/dlls/mshtml/htmlbody.c
@@ -635,7 +635,7 @@ static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v
 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
 {
     HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
-    const WCHAR *ret;
+    const WCHAR *ret = NULL;
     BSTR overflow;
     HRESULT hres;
 
@@ -648,7 +648,7 @@ static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *
 
     if(!overflow || !*overflow) {
         *p = NULL;
-        return S_OK;
+        hres = S_OK;
     }else if(!strcmpW(overflow, visibleW) || !strcmpW(overflow, autoW)) {
         ret = autoW;
     }else if(!strcmpW(overflow, scrollW)) {
@@ -658,11 +658,16 @@ static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *
     }else {
         TRACE("Defaulting %s to NULL\n", debugstr_w(overflow));
         *p = NULL;
-        return S_OK;
+        hres = S_OK;
     }
 
-    *p = SysAllocString(ret);
-    return *p ? S_OK : E_OUTOFMEMORY;
+    SysFreeString(overflow);
+    if(ret) {
+        *p = SysAllocString(ret);
+        hres = *p ? S_OK : E_OUTOFMEMORY;
+    }
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)




More information about the wine-cvs mailing list