Bug 1883844 - Adding missing oom-handling in wasmMetadataAnalysis. r=anba

Differential Revision: https://phabricator.services.mozilla.com/D203979
This commit is contained in:
Julien Pages 2024-03-08 16:13:19 +00:00
parent dad8b74c02
commit 02b1170a8f

View file

@ -2094,6 +2094,7 @@ static bool wasmMetadataAnalysis(JSContext* cx, unsigned argc, Value* vp) {
.metadataAnalysis(cx);
if (hashmap.empty()) {
JS_ReportErrorASCII(cx, "Metadata analysis has failed");
return false;
}
// metadataAnalysis returned a map of {key, value} with various statistics
@ -2105,16 +2106,22 @@ static bool wasmMetadataAnalysis(JSContext* cx, unsigned argc, Value* vp) {
auto value = iter.get().value();
JSString* string = JS_NewStringCopyZ(cx, key);
if (!string) {
return false;
}
if (!props.append(
IdValuePair(NameToId(string->asLinear().toPropertyName(cx)),
NumberValue(value)))) {
ReportOutOfMemory(cx);
return false;
}
}
JSObject* results =
NewPlainObjectWithUniqueNames(cx, props.begin(), props.length());
if (!results) {
return false;
}
args.rval().setObject(*results);
return true;