Bug 743961 - Null-check context pushing callbacks. r=mrbkap, a=akeybl
authorBobby Holley <bobbyholley@gmail.com>
Mon, 07 May 2012 10:12:08 +0200
changeset 95641 bf656bbd74bbe22b31a4967210988aca4b9e4d53
parent 95640 8c8e96d70ab518e182db32747b2d8706ad60bb7e
child 95642 37b8a2df105d4b693e08ba4d93c5c14e8e45f43c
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, akeybl
bugs743961
milestone14.0a2
Bug 743961 - Null-check context pushing callbacks. r=mrbkap, a=akeybl
js/src/jit-test/tests/basic/bug743961.js
js/src/jsclone.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug743961.js
@@ -0,0 +1,2 @@
+var n = (evalcx('lazy'));
+try { var nbuf = serialize(n); } catch(e) {} // Don't crash
--- a/js/src/jsclone.cpp
+++ b/js/src/jsclone.cpp
@@ -513,25 +513,28 @@ class AutoEnterCompartmentAndPushPrincip
             return false;
 
         // We only need to push a principal if we changed compartments.
         if (state != STATE_OTHER_COMPARTMENT)
             return true;
 
         // Push.
         const JSSecurityCallbacks *cb = cx->runtime->securityCallbacks;
-        return cb->pushContextPrincipal(cx, target->principals(cx));
+        if (cb->pushContextPrincipal)
+          return cb->pushContextPrincipal(cx, target->principals(cx));
+        return true;
     };
 
     ~AutoEnterCompartmentAndPushPrincipal() {
         // Pop the principal if necessary.
         if (state == STATE_OTHER_COMPARTMENT) {
             AutoCompartment *ac = getAutoCompartment();
             const JSSecurityCallbacks *cb = ac->context->runtime->securityCallbacks;
-            cb->popContextPrincipal(ac->context);
+            if (cb->popContextPrincipal)
+              cb->popContextPrincipal(ac->context);
         }
     };
 };
 
 
 bool
 JSStructuredCloneWriter::startWrite(const Value &v)
 {