summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 9118eaae1..1c8377127 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1617,6 +1617,13 @@ public:
}
const auto& element = curr->rtt->type.getHeapType().getArray().element;
Index num = size.getSingleValue().geti32();
+ // Arbitrary deterministic limit on size. If we need to allocate a Literals
+ // vector that takes around 1-2GB of memory then we are likely to hit memory
+ // limits on 32-bit machines, and in particular on wasm32 VMs that do not
+ // have 4GB support, so give up there.
+ if (num >= (1 << 30) / sizeof(Literal)) {
+ trap("allocation failure");
+ }
Literals data(num);
if (curr->isWithDefault()) {
for (Index i = 0; i < num; i++) {