Jacek Caban : mshtml: Properly handle OOM errors in script.c (coverity).

Alexandre Julliard julliard at winehq.org
Fri Oct 19 13:33:53 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Oct 19 11:57:30 2012 +0200

mshtml: Properly handle OOM errors in script.c (coverity).

---

 dlls/mshtml/script.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index d99269a..90f9ba0 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -666,6 +666,9 @@ static ScriptHost *create_script_host(HTMLInnerWindow *window, const GUID *guid)
     HRESULT hres;
 
     ret = heap_alloc_zero(sizeof(*ret));
+    if(!ret)
+        return NULL;
+
     ret->IActiveScriptSite_iface.lpVtbl = &ActiveScriptSiteVtbl;
     ret->IActiveScriptSiteInterruptPoll_iface.lpVtbl = &ActiveScriptSiteInterruptPollVtbl;
     ret->IActiveScriptSiteWindow_iface.lpVtbl = &ActiveScriptSiteWindowVtbl;
@@ -944,6 +947,9 @@ IDispatch *script_parse_event(HTMLInnerWindow *window, LPCWSTR text)
         BOOL b;
 
         language = heap_alloc((ptr-text+1)*sizeof(WCHAR));
+        if(!language)
+            return NULL;
+
         memcpy(language, text, (ptr-text)*sizeof(WCHAR));
         language[ptr-text] = 0;
 
@@ -1207,9 +1213,10 @@ void bind_event_scripts(HTMLDocumentNode *doc)
         if(event_disp) {
             event_target = find_event_target(doc, script_elem);
             if(event_target) {
-                IHTMLElement_QueryInterface(&event_target->IHTMLElement_iface, &IID_HTMLPluginContainer, (void**)&plugin_container);
+                hres = IHTMLElement_QueryInterface(&event_target->IHTMLElement_iface, &IID_HTMLPluginContainer,
+                        (void**)&plugin_container);
 
-                if(plugin_container)
+                if(SUCCEEDED(hres))
                     bind_activex_event(doc, plugin_container, event, event_disp);
                 else
                     bind_elem_event(doc, event_target, event, event_disp);




More information about the wine-cvs mailing list