Bug 2067107 - Check string allocation in ModuleLoader::CreateTextModule. r=dom-core-reviewers,jjaschke
Differential Revision: https://phabricator.services.mozilla.com/D325000
This commit is contained in:
committed by
earo@mozilla.com
parent
aed6a14648
commit
8398fd4d32
@@ -592,7 +592,7 @@ nsresult ModuleLoader::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>&>);
|
||||
@@ -604,6 +604,9 @@ nsresult ModuleLoader::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