Bug 1315839: Add null-check in wasmExtractCode; r=luke
authorBenjamin Bouvier <benj@benj.me>
Tue, 08 Nov 2016 10:06:26 +0100
changeset 321744 5189ddac9614b043e29eee5e60981ac07ce2303c
parent 321743 38f5ec02b1d669c4e2894075da59d3e0d354aeb3
child 321745 62b32efde227dd15715fee36cfdd92199c4ce12a
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
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;