[PATCH] check for This->ctx and This->site earlier (Coverity)

Marcus Meissner marcus at jet.franken.de
Tue Oct 14 02:59:33 CDT 2008


Hi,

Coverity IDs 780 and 779, a This->something->foo is
used with This->something checked later on.

I moved the This->something checks up before those usages.

Ciao, Marcus
---
 dlls/jscript/jscript.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 41fb40f..081f468 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -306,23 +306,24 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
 
     clear_script_queue(This);
 
-    if(This->ctx->named_items) {
-        named_item_t *iter, *iter2;
+    if(This->ctx) {
+        if(This->ctx->named_items) {
+            named_item_t *iter, *iter2;
 
-        iter = This->ctx->named_items;
-        while(iter) {
-            iter2 = iter->next;
+            iter = This->ctx->named_items;
+            while(iter) {
+                iter2 = iter->next;
 
-            IDispatch_Release(iter->disp);
-            heap_free(iter);
-            iter = iter2;
-        }
+                IDispatch_Release(iter->disp);
+                heap_free(iter);
+                iter = iter2;
+            }
 
-        This->ctx->named_items = NULL;
-    }
+            This->ctx->named_items = NULL;
+        }
 
-    if(This->ctx) {
-        change_state(This, SCRIPTSTATE_CLOSED);
+        if (This->site)
+            change_state(This, SCRIPTSTATE_CLOSED);
 
         if(This->ctx->script_disp) {
             IDispatchEx_Release(_IDispatchEx_(This->ctx->script_disp));
-- 
1.5.6



More information about the wine-patches mailing list