Bug 1315839: Add null-check in wasmExtractCode; r=luke
authorBenjamin Bouvier <benj@benj.me>
Tue, 08 Nov 2016 10:06:26 +0100
changeset 351761 5189ddac9614b043e29eee5e60981ac07ce2303c
parent 351760 38f5ec02b1d669c4e2894075da59d3e0d354aeb3
child 351762 62b32efde227dd15715fee36cfdd92199c4ce12a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1315839
milestone52.0a1
Bug 1315839: Add null-check in wasmExtractCode; r=luke MozReview-Commit-ID: GIyAn5TLwhC
js/src/wasm/WasmModule.cpp
--- a/js/src/wasm/WasmModule.cpp
+++ b/js/src/wasm/WasmModule.cpp
@@ -521,38 +521,47 @@ Module::extractCode(JSContext* cx, Mutab
     RootedValue value(cx, ObjectValue(*code));
     if (!JS_DefineProperty(cx, result, "code", value, JSPROP_ENUMERATE))
         return false;
 
     RootedObject segments(cx, NewDenseEmptyArray(cx));
     if (!segments)
         return false;
 
-    for (auto p = metadata_->codeRanges.begin(); p != metadata_->codeRanges.end(); p++) {
+    for (const CodeRange& p : metadata_->codeRanges) {
         RootedObject segment(cx, NewObjectWithGivenProto<PlainObject>(cx, nullptr));
-        value.setNumber((uint32_t)p->begin());
+        if (!segment)
+            return false;
+
+        value.setNumber((uint32_t)p.begin());
         if (!JS_DefineProperty(cx, segment, "begin", value, JSPROP_ENUMERATE))
             return false;
-        value.setNumber((uint32_t)p->end());
+
+        value.setNumber((uint32_t)p.end());
         if (!JS_DefineProperty(cx, segment, "end", value, JSPROP_ENUMERATE))
             return false;
-        value.setNumber((uint32_t)p->kind());
+
+        value.setNumber((uint32_t)p.kind());
         if (!JS_DefineProperty(cx, segment, "kind", value, JSPROP_ENUMERATE))
             return false;
-        if (p->isFunction()) {
-            value.setNumber((uint32_t)p->funcIndex());
+
+        if (p.isFunction()) {
+            value.setNumber((uint32_t)p.funcIndex());
             if (!JS_DefineProperty(cx, segment, "funcIndex", value, JSPROP_ENUMERATE))
                 return false;
-            value.setNumber((uint32_t)p->funcNonProfilingEntry());
+
+            value.setNumber((uint32_t)p.funcNonProfilingEntry());
             if (!JS_DefineProperty(cx, segment, "funcBodyBegin", value, JSPROP_ENUMERATE))
                 return false;
-            value.setNumber((uint32_t)p->funcProfilingEpilogue());
+
+            value.setNumber((uint32_t)p.funcProfilingEpilogue());
             if (!JS_DefineProperty(cx, segment, "funcBodyEnd", value, JSPROP_ENUMERATE))
                 return false;
         }
+
         if (!NewbornArrayPush(cx, segments, ObjectValue(*segment)))
             return false;
     }
 
     value.setObject(*segments);
     if (!JS_DefineProperty(cx, result, "segments", value, JSPROP_ENUMERATE))
         return false;