summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-11-14 10:52:41 -0800
committerGitHub <noreply@github.com>2017-11-14 10:52:41 -0800
commit47a27b1ae440cec5272c4460f3a6c2e0b3e97021 (patch)
tree6e7e33dda010b312bb2e684efaf62e43d37cbaf2 /src
parent4231ff2f3c9bcbaa639659b39618e4a46db9eb23 (diff)
downloadbinaryen-47a27b1ae440cec5272c4460f3a6c2e0b3e97021.tar.gz
binaryen-47a27b1ae440cec5272c4460f3a6c2e0b3e97021.tar.bz2
binaryen-47a27b1ae440cec5272c4460f3a6c2e0b3e97021.zip
accept overlapping segments (#1289)
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-validator.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 4564191c2..ef70cc9e7 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -965,18 +965,15 @@ static void validateMemory(Module& module, ValidationInfo& info) {
info.shouldBeTrue(curr.max <= Memory::kMaxSize, "memory", "max memory must be <= 4GB");
info.shouldBeTrue(!curr.shared || curr.hasMax(), "memory", "shared memory must have max size");
if (curr.shared) info.shouldBeTrue(info.features & Feature::Atomics, "memory", "memory is shared, but atomics are disabled");
- Index mustBeGreaterOrEqual = 0;
for (auto& segment : curr.segments) {
if (!info.shouldBeEqual(segment.offset->type, i32, segment.offset, "segment offset should be i32")) continue;
info.shouldBeTrue(checkOffset(segment.offset, segment.data.size(), module.memory.initial * Memory::kPageSize), segment.offset, "segment offset should be reasonable");
Index size = segment.data.size();
- info.shouldBeTrue(size <= curr.initial * Memory::kPageSize, segment.data.size(), "segment size should fit in memory");
+ info.shouldBeTrue(size <= curr.initial * Memory::kPageSize, segment.data.size(), "segment size should fit in memory (initial)");
if (segment.offset->is<Const>()) {
Index start = segment.offset->cast<Const>()->value.geti32();
Index end = start + size;
- info.shouldBeTrue(end <= curr.initial * Memory::kPageSize, segment.data.size(), "segment size should fit in memory");
- info.shouldBeTrue(start >= mustBeGreaterOrEqual, segment.data.size(), "segment size should fit in memory");
- mustBeGreaterOrEqual = end;
+ info.shouldBeTrue(end <= curr.initial * Memory::kPageSize, segment.data.size(), "segment size should fit in memory (end)");
}
}
}