Commit 05c4afb0 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] void is not a valid type for a global.

TEST=unittest WasmModuleVerifyTest.Global_invalid_type2
BUG=chromium:645443
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2342593002
Cr-Commit-Position: refs/heads/master@{#39421}
parent 7954b3f8
......@@ -467,6 +467,9 @@ class ModuleDecoder : public Decoder {
error("global name is not valid utf8");
}
global->type = consume_local_type();
if (global->type == kAstStmt) {
error("invalid global type");
}
global->offset = 0;
global->exported = consume_u8("exported") != 0;
}
......
......@@ -213,7 +213,22 @@ TEST_F(WasmModuleVerifyTest, Global_invalid_type) {
0, // exported
};
ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data));
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_FALSE(result.ok());
if (result.val) delete result.val;
}
TEST_F(WasmModuleVerifyTest, Global_invalid_type2) {
static const byte data[] = {
SECTION(GLOBALS, 5), // --
1,
NAME_LENGTH(1),
'g', // name
kLocalVoid, // invalid memory type
0, // exported
};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_FALSE(result.ok());
if (result.val) delete result.val;
}
......
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