Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1122)

Unified Diff: src/wasm/wasm-module.cc

Issue 1967023004: [wasm] Add UTF-8 validation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add titzer's comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 9ec439d4b5192229dea9573907e2236830cc3135..55bb7d973cf297f3a23da000fb6c135a5462174a 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -553,9 +553,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
WasmName str = GetName(func.name_offset, func.name_length);
WasmName str_null = {nullptr, 0};
- Handle<String> name = factory->InternalizeUtf8String(str);
Handle<Code> code = Handle<Code>::null();
Handle<JSFunction> function = Handle<JSFunction>::null();
+ Handle<String> functionName;
if (func.external) {
// Lookup external function in FFI object.
MaybeHandle<JSFunction> function =
@@ -578,8 +578,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
return MaybeHandle<JSObject>();
}
if (func.exported) {
+ functionName = factory->InternalizeUtf8String(str);
function = compiler::CompileJSToWasmWrapper(
- isolate, &module_env, name, code, instance.js_object, i);
+ isolate, &module_env, functionName, code, instance.js_object, i);
record_code_size(function->code());
}
}
@@ -589,12 +590,13 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
code_table->set(i, *code);
record_code_size(*code);
}
- if (func.exported) {
+ if (!function.is_null()) {
// Exported functions are installed as read-only properties on the
// module.
desc.set_value(function);
Maybe<bool> status = JSReceiver::DefineOwnProperty(
- isolate, instance.js_object, name, &desc, Object::THROW_ON_ERROR);
+ isolate, instance.js_object, functionName, &desc,
+ Object::THROW_ON_ERROR);
if (!status.IsJust())
thrower.Error("export of %.*s failed.", str.length(), str.start());
}

Powered by Google App Engine
This is Rietveld 408576698