Do things in a different order. Bug 482861. r=jwalden
authorRobert Sayre <sayrer@gmail.com>
Thu, 12 Mar 2009 02:18:59 -0400
changeset 24131 7b5a3f6ade948dd4e5d2a11ab018d87bd9ee59ad
parent 24130 9af591a32e8f93a14a17a7653da57f2b1e4167ed
child 24132 82f3482bfd37c75866316b52f14034fc9c82a560
push id1055
push userrsayre@mozilla.com
push dateTue, 31 Mar 2009 22:02:07 +0000
reviewersjwalden
bugs482861
milestone1.9.1b4pre
Do things in a different order. Bug 482861. r=jwalden
js/src/json.cpp
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -586,23 +586,24 @@ js_FinishJSONParse(JSContext *cx, JSONPa
 
     if (jp->buffer)
         js_FinishStringBuffer(jp->buffer);
     JS_free(cx, jp->buffer);
 
     if (!js_RemoveRoot(cx->runtime, &jp->objectStack))
         return JS_FALSE;
     JSBool ok = *jp->statep == JSON_PARSE_STATE_FINISHED;
+    jsval *v = jp->rootVal;
     JS_free(cx, jp);
 
     if (!ok)
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
 
     if (!JSVAL_IS_PRIMITIVE(reviver) && js_IsCallable(JSVAL_TO_OBJECT(reviver), cx))
-        ok = Revive(cx, reviver, jp->rootVal);
+        ok = Revive(cx, reviver, v);
 
     return ok;
 }
 
 static JSBool
 PushState(JSContext *cx, JSONParser *jp, JSONParserState state)
 {
     if (*jp->statep == JSON_PARSE_STATE_FINISHED) {