From b24f815b4b14ae8e9cdcd0f9aee85aa3c619ba09 Mon Sep 17 00:00:00 2001 From: sxvncry <160118530+sxvncry@users.noreply.github.com> Date: Tue, 15 Sep 2026 18:04:57 +0700 Subject: [PATCH] wasm2c: fail closed when table allocation runs out of memory --- wasm2c/wasm-rt-impl-tableops.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wasm2c/wasm-rt-impl-tableops.inc b/wasm2c/wasm-rt-impl-tableops.inc index 323a32f8db..82ff7907b1 100644 --- a/wasm2c/wasm-rt-impl-tableops.inc +++ b/wasm2c/wasm-rt-impl-tableops.inc @@ -52,6 +52,9 @@ void WASM_RT_TABLE_APINAME(wasm_rt_allocate)(WASM_RT_TABLE_TYPE* table, table->size = elements; table->max_size = max_elements; table->data = calloc(table->size, sizeof(WASM_RT_TABLE_ELEMENT_TYPE)); + if (table->size != 0 && !table->data) { + abort(); + } } void WASM_RT_TABLE_APINAME(wasm_rt_free)(WASM_RT_TABLE_TYPE* table) {