forked from mirrors/gecko-dev
Bug 1883844 - Adding missing oom-handling in wasmMetadataAnalysis. r=anba
Differential Revision: https://phabricator.services.mozilla.com/D203979
This commit is contained in:
parent
dad8b74c02
commit
02b1170a8f
1 changed files with 8 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue