Bug 1356546: Follow-up: Fix rooting hazard warning.
authorKris Maglione <maglione.k@gmail.com>
Mon, 05 Jun 2017 00:13:15 -0700
changeset 410433 0534d36df322f8d1b806cef0705733cdf3f7b89f
parent 410432 af18a71db2946e60778fc8c4666fad11e883eb49
child 410434 15c554f1a294dfdab0fbdda3a25a8467ef071b79
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1356546
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1356546: Follow-up: Fix rooting hazard warning. MozReview-Commit-ID: JDDjiEbbErK
dom/base/StructuredCloneBlob.cpp
--- a/dom/base/StructuredCloneBlob.cpp
+++ b/dom/base/StructuredCloneBlob.cpp
@@ -89,27 +89,26 @@ StructuredCloneBlob::Deserialize(JSConte
     aRv.NoteJSContextException(aCx);
   }
 }
 
 
 /* static */ JSObject*
 StructuredCloneBlob::ReadStructuredClone(JSContext* aCx, JSStructuredCloneReader* aReader)
 {
-  RefPtr<StructuredCloneBlob> holder = new StructuredCloneBlob();
-
-  if (!holder->ReadStructuredCloneInternal(aCx, aReader)) {
-    return nullptr;
-  }
+  JS::RootedObject obj(aCx);
+  {
+    RefPtr<StructuredCloneBlob> holder = new StructuredCloneBlob();
 
-  JS::RootedObject obj(aCx);
-  if (holder->WrapObject(aCx, nullptr, &obj)) {
-    return obj.get();
+    if (!holder->ReadStructuredCloneInternal(aCx, aReader) ||
+        !holder->WrapObject(aCx, nullptr, &obj)) {
+      return nullptr;
+    }
   }
-  return nullptr;
+  return obj.get();
 }
 
 bool
 StructuredCloneBlob::ReadStructuredCloneInternal(JSContext* aCx, JSStructuredCloneReader* aReader)
 {
   uint32_t length;
   uint32_t version;
   if (!JS_ReadUint32Pair(aReader, &length, &version)) {