Bug 1239369 - Add some missing calls to ReportOutOfMemory r=terrence
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -231,17 +231,22 @@ IndirectBindingMap::trace(JSTracer* trc)
}
bool
IndirectBindingMap::putNew(JSContext* cx, HandleId name,
HandleModuleEnvironmentObject environment, HandleId localName)
{
RootedShape shape(cx, environment->lookup(cx, localName));
MOZ_ASSERT(shape);
- return map_.putNew(name, Binding(environment, shape));
+ if (!map_.putNew(name, Binding(environment, shape))) {
+ ReportOutOfMemory(cx);
+ return false;
+ }
+
+ return true;
}
bool
IndirectBindingMap::lookup(jsid name, ModuleEnvironmentObject** envOut, Shape** shapeOut) const
{
auto ptr = map_.lookup(name);
if (!ptr)
return false;
@@ -757,17 +762,22 @@ ModuleObject::createEnvironment()
MOZ_ASSERT(getReservedSlot(EnvironmentSlot).isUndefined());
setReservedSlot(EnvironmentSlot, getReservedSlot(InitialEnvironmentSlot));
}
bool
ModuleObject::noteFunctionDeclaration(ExclusiveContext* cx, HandleAtom name, HandleFunction fun)
{
FunctionDeclarationVector* funDecls = functionDeclarations();
- return funDecls->emplaceBack(name, fun);
+ if (!funDecls->emplaceBack(name, fun)) {
+ ReportOutOfMemory(cx);
+ return false;
+ }
+
+ return true;
}
/* static */ bool
ModuleObject::instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject self)
{
FunctionDeclarationVector* funDecls = self->functionDeclarations();
if (!funDecls) {
JS_ReportError(cx, "Module function declarations have already been instantiated");
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -1144,18 +1144,20 @@ InitFromBailout(JSContext* cx, HandleScr
if (cx->runtime()->spsProfiler.enabled()) {
// Register bailout with profiler.
const char* filename = script->filename();
if (filename == nullptr)
filename = "<unknown>";
unsigned len = strlen(filename) + 200;
char* buf = js_pod_malloc<char>(len);
- if (buf == nullptr)
+ if (buf == nullptr) {
+ ReportOutOfMemory(cx);
return false;
+ }
JS_snprintf(buf, len, "%s %s %s on line %u of %s:%" PRIuSIZE,
BailoutKindString(bailoutKind),
resumeAfter ? "after" : "at",
CodeName[op],
PCToLineNumber(script, pc),
filename,
script->lineno());
cx->runtime()->spsProfiler.markEvent(buf);