Bug 1320374: Add missing null-checks; r=bustage
authorBenjamin Bouvier <benj@benj.me>
Tue, 29 Nov 2016 17:23:54 +0100
changeset 324713 b24e8ff760ba7b27b8ba2fceb9a90bd079b7bd19
parent 324712 0a18b6782086a5467d0203a542ab75ebc66ad809
child 324714 e6459d80bf245d1f5e2f46bda884878548d58126
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbustage
bugs1320374
milestone53.0a1
Bug 1320374: Add missing null-checks; r=bustage
js/src/wasm/WasmGenerator.cpp
--- a/js/src/wasm/WasmGenerator.cpp
+++ b/js/src/wasm/WasmGenerator.cpp
@@ -854,18 +854,22 @@ ModuleGenerator::startFuncDefs()
 
     if (!freeTasks_.reserve(numTasks))
         return false;
     for (size_t i = 0; i < numTasks; i++)
         freeTasks_.infallibleAppend(&tasks_[i]);
 
     if (!freeBytes_.reserve(numTasks))
         return false;
-    for (size_t i = 0; i < numTasks; i++)
-        freeBytes_.infallibleAppend(js::MakeUnique<Bytes>());
+    for (size_t i = 0; i < numTasks; i++) {
+        auto bytes = js::MakeUnique<Bytes>();
+        if (!bytes)
+            return false;
+        freeBytes_.infallibleAppend(Move(bytes));
+    }
 
     startedFuncDefs_ = true;
     MOZ_ASSERT(!finishedFuncDefs_);
     return true;
 }
 
 bool
 ModuleGenerator::startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg)
@@ -874,16 +878,18 @@ ModuleGenerator::startFuncDef(uint32_t l
     MOZ_ASSERT(!activeFuncDef_);
     MOZ_ASSERT(!finishedFuncDefs_);
 
     if (!freeBytes_.empty()) {
         fg->bytes_ = Move(freeBytes_.back());
         freeBytes_.popBack();
     } else {
         fg->bytes_ = js::MakeUnique<Bytes>();
+        if (!fg->bytes_)
+            return false;
     }
 
     fg->lineOrBytecode_ = lineOrBytecode;
     fg->m_ = this;
     activeFuncDef_ = fg;
     return true;
 }