Bug 2067109 - Check string allocation in WorkletModuleLoader::CreateTextModule. r=dom-core-reviewers,jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D325002
This commit is contained in:
committed by
earo@mozilla.com
parent
c81b3051a4
commit
62803d7584
@@ -201,7 +201,7 @@ nsresult WorkletModuleLoader::CreateTextModule(
|
||||
aRequest->mLoadContext.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto compile = [&](auto& source) {
|
||||
auto compile = [&](auto& source) -> JSObject* {
|
||||
using T = decltype(source);
|
||||
static_assert(std::is_same_v<T, JS::SourceText<char16_t>&> ||
|
||||
std::is_same_v<T, JS::SourceText<Utf8Unit>&>);
|
||||
@@ -213,6 +213,9 @@ nsresult WorkletModuleLoader::CreateTextModule(
|
||||
} else {
|
||||
str = JS_NewUCStringCopyN(aCx, source.get(), source.length());
|
||||
}
|
||||
if (!str) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> defaultExport(aCx, JS::StringValue(str));
|
||||
return JS::CreateDefaultExportSyntheticModule(aCx, defaultExport);
|
||||
|
||||
Reference in New Issue
Block a user