Bug 1307633 - XDRScript: Do not attempt to free 0-initialized scriptData_ on OOM. r=shu
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 15 Jun 2017 12:32:27 +0000
changeset 364164 726d125c339b2aeaccce67a7d40b8a4fdb38c826
parent 364163 d12ee58d7b27122e02b66dfebe674977f7d5ebaa
child 364165 31758734ff3c4cc3fc20b6391be3655e56e3577a
push id44817
push userarchaeopteryx@coole-files.de
push dateThu, 15 Jun 2017 18:14:06 +0000
treeherderautoland@2cdb9790628f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1307633
milestone56.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 1307633 - XDRScript: Do not attempt to free 0-initialized scriptData_ on OOM. r=shu
js/src/jsscript.cpp
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -659,26 +659,27 @@ js::XDRScript(XDRState<mode>* xdr, Handl
     if (mode == XDR_DECODE) {
         script->lineno_ = lineno;
         script->column_ = column;
         script->nfixed_ = nfixed;
         script->nslots_ = nslots;
         script->bodyScopeIndex_ = bodyScopeIndex;
     }
 
+    if (mode == XDR_DECODE) {
+        if (!script->createScriptData(cx, length, nsrcnotes, natoms)) {
+            return false;
+        }
+    }
+
     auto scriptDataGuard = mozilla::MakeScopeExit([&] {
         if (mode == XDR_DECODE)
             script->freeScriptData();
     });
 
-    if (mode == XDR_DECODE) {
-        if (!script->createScriptData(cx, length, nsrcnotes, natoms))
-            return false;
-    }
-
     jsbytecode* code = script->code();
     if (!xdr->codeBytes(code, length) || !xdr->codeBytes(code + length, nsrcnotes)) {
         return false;
     }
 
     for (i = 0; i != natoms; ++i) {
         if (mode == XDR_DECODE) {
             RootedAtom tmp(cx);