Bug 1394493 - Check for uninitialised lexicals in getModuleEnvironmentValue() r=arai

This commit is contained in:
Jon Coppeard 2017-09-01 10:14:11 +01:00
parent 47659f1db3
commit f624c0f438
2 changed files with 13 additions and 1 deletions

View File

@ -3979,7 +3979,15 @@ GetModuleEnvironmentValue(JSContext* cx, unsigned argc, Value* vp)
if (!JS_StringToId(cx, name, &id))
return false;
return GetProperty(cx, env, env, id, args.rval());
if (!GetProperty(cx, env, env, id, args.rval()))
return false;
if (args.rval().isMagic(JS_UNINITIALIZED_LEXICAL)) {
ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, id);
return false;
}
return true;
}
#ifdef DEBUG

View File

@ -0,0 +1,4 @@
// |jit-test| error: ReferenceError
let m = parseModule("export let r = y; y = 4;");
getModuleEnvironmentValue(m, "r").toString()