Commit 0b919529 authored by titzer's avatar titzer Committed by Commit bot

[asmjs] Validator should reject modules with repeated functions.

R=ahaas@chromium.org,aseemgarg@chromium.org,bradnelson@chromium.org
BUG=chromium:617525

Review-Url: https://codereview.chromium.org/2040983002
Cr-Commit-Position: refs/heads/master@{#36748}
parent dc98fabf
......@@ -166,6 +166,10 @@ void AsmTyper::VisitFunctionDeclaration(FunctionDeclaration* decl) {
// Set function type so global references to functions have some type
// (so they can give a more useful error).
Variable* var = decl->proxy()->var();
if (GetVariableInfo(var)) {
// Detect previously-seen functions.
FAIL(decl->fun(), "function repeated in module");
}
SetType(var, Type::Function());
}
......
......@@ -1361,6 +1361,12 @@ TEST(CompareMismatchInt32Float32) {
"asm: line 1: left and right side of comparison must match\n");
}
TEST(FunctionRepeated) {
CHECK_FUNC_ERROR(
"function foo() { return 0; }\n"
"function foo() { return 0; }",
"asm: line 2: function repeated in module\n");
}
TEST(Float64ToInt32) {
CHECK_FUNC_TYPES_BEGIN(
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function __f_14() {
"use asm";
function __f_15() { return 0; }
function __f_15() { return 137; } // redeclared function
return {};
}
assertThrows(function() { Wasm.instantiateModuleFromAsm(__f_14.toString()) });
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