Bug 2067108 - Check string allocation in WorkerModuleLoader::CreateTextModule. r=edenchuang
Differential Revision: https://phabricator.services.mozilla.com/D325001
This commit is contained in:
committed by
earo@mozilla.com
parent
8398fd4d32
commit
c81b3051a4
@@ -244,7 +244,7 @@ nsresult WorkerModuleLoader::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>&>);
|
||||
@@ -256,6 +256,9 @@ nsresult WorkerModuleLoader::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