Bug 616412: Fix use-before-init bug. r=mrbkap a=a
authorChris Jones <jones.chris.g@gmail.com>
Tue, 04 Jan 2011 10:40:54 -0600
changeset 59842 6e9e376c146bb6c7e0d837595f7297a37f592fbd
parent 59841 a7d7ed0cda707393db783d2733c8ae0ccfa41643
child 59843 53958cd8b5284d887f71b459dc024d25407ae5bf
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersmrbkap, a
bugs616412
milestone2.0b9pre
Bug 616412: Fix use-before-init bug. r=mrbkap a=a
caps/src/nsScriptSecurityManager.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -2172,30 +2172,31 @@ nsScriptSecurityManager::GetScriptPrinci
 // static
 nsIPrincipal*
 nsScriptSecurityManager::GetFunctionObjectPrincipal(JSContext *cx,
                                                     JSObject *obj,
                                                     JSStackFrame *fp,
                                                     nsresult *rv)
 {
     NS_PRECONDITION(rv, "Null out param");
+
+    *rv = NS_OK;
+
     if (!JS_ObjectIsFunction(cx, obj))
     {
         // Protect against pseudo-functions (like SJOWs).
         nsIPrincipal *result = doGetObjectPrincipal(obj);
         if (!result)
             *rv = NS_ERROR_FAILURE;
         return result;
     }
 
     JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
     JSScript *script = JS_GetFunctionScript(cx, fun);
 
-    *rv = NS_OK;
-
     if (!script)
     {
         // A native function: skip it in order to find its scripted caller.
         return nsnull;
     }
 
     JSScript *frameScript = fp ? JS_GetFrameScript(cx, fp) : nsnull;