Bug 1345868 - Don't assert when calling getModuleLoadPath in workers. r=jonco
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 10 Apr 2017 13:29:50 +0200
changeset 560291 82fba63ab05634d20ca36fa78249d57fafd092fd
parent 560290 540fcd0fa44edcb242a5ff44162a03cc880a88f0
child 560292 a813601f912ceb40ff643f9f12d406eca6a74e8a
push id53365
push userjichen@mozilla.com
push dateTue, 11 Apr 2017 08:35:12 +0000
reviewersjonco
bugs1345868
milestone55.0a1
Bug 1345868 - Don't assert when calling getModuleLoadPath in workers. r=jonco
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -4358,18 +4358,25 @@ SetModuleResolveHook(JSContext* cx, unsi
 }
 
 static bool
 GetModuleLoadPath(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     ShellContext* sc = GetShellContext(cx);
-    MOZ_ASSERT(sc->moduleLoadPath);
-    args.rval().setString(JS_NewStringCopyZ(cx, sc->moduleLoadPath.get()));
+    if (sc->moduleLoadPath) {
+        JSString* str = JS_NewStringCopyZ(cx, sc->moduleLoadPath.get());
+        if (!str)
+            return false;
+
+        args.rval().setString(str);
+    } else {
+        args.rval().setNull();
+    }
     return true;
 }
 
 static bool
 Parse(JSContext* cx, unsigned argc, Value* vp)
 {
     using namespace js::frontend;