Commit 4ae08567 authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Bug 1663862 - Check OOM from wasm::ToString(). r=lth, a=RyanVM

wasm::ToCString() couldn't OOM, but wasm::ToString() can, so the
all the use cases need to check for OOM and propagate it.

Differential Revision: https://phabricator.services.mozilla.com/D89671
parent f761ae40
......@@ -1162,6 +1162,10 @@ static JSString* FuncTypeToString(JSContext* cx, const FuncType& funcType) {
}
UniqueChars argStr = ToString(arg);
if (!argStr) {
return nullptr;
}
if (!buf.append(argStr.get(), strlen(argStr.get()))) {
return nullptr;
}
......@@ -1180,6 +1184,10 @@ static JSString* FuncTypeToString(JSContext* cx, const FuncType& funcType) {
}
UniqueChars resultStr = ToString(result);
if (!resultStr) {
return nullptr;
}
if (!buf.append(resultStr.get(), strlen(resultStr.get()))) {
return nullptr;
}
......
......@@ -570,7 +570,15 @@ inline bool OpIter<Policy>::checkIsSubtypeOf(ValType actual, ValType expected) {
}
UniqueChars actualText = ToString(actual);
if (!actualText) {
return false;
}
UniqueChars expectedText = ToString(expected);
if (!expectedText) {
return false;
}
UniqueChars error(
JS_smprintf("type mismatch: expression has type %s but expected %s",
actualText.get(), expectedText.get()));
......@@ -691,6 +699,10 @@ inline bool OpIter<Policy>::popWithRefType(Value* value) {
}
UniqueChars actualText = ToString(stackType.valType());
if (!actualText) {
return false;
}
UniqueChars error(JS_smprintf(
"type mismatch: expression has type %s but expected a reference type",
actualText.get()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment