Commit ce291bed authored by titzer's avatar titzer Committed by Commit bot

[wasm] Dont compute global offsets if the module had errors (e.g. invalid memory type for global).

R=ahaas@chromium.org,bradnelson@chromium.org
BUG=chromium:617884

Review-Url: https://codereview.chromium.org/2044833002
Cr-Commit-Position: refs/heads/master@{#36779}
parent 4620e294
......@@ -384,7 +384,7 @@ class ModuleDecoder : public Decoder {
}
done:
CalculateGlobalsOffsets(module);
if (ok()) CalculateGlobalsOffsets(module);
const WasmModule* finished_module = module;
ModuleResult result = toResult(finished_module);
if (FLAG_dump_wasm_module) {
......
......@@ -201,6 +201,21 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) {
EXPECT_OFF_END_FAILURE(data, 1, sizeof(data));
}
TEST_F(WasmModuleVerifyTest, Global_invalid_type) {
static const byte data[] = {
SECTION(GLOBALS, 5), // --
1,
NAME_LENGTH(1),
'g', // name
64, // invalid memory type
0, // exported
};
ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data));
EXPECT_FALSE(result.ok());
if (result.val) delete result.val;
}
TEST_F(WasmModuleVerifyTest, ZeroGlobals) {
static const byte data[] = {
SECTION(GLOBALS, 1), // --
......
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