From c304fecfdda29149dd489c1afa7a8978c8486b16 Mon Sep 17 00:00:00 2001 From: Brandon Payton Date: Wed, 10 Apr 2024 20:54:27 -0600 Subject: [PATCH] Zero memory allocated by wasm_memory_storage --- .../compile/php-wasm-memory-storage/wasm_memory_storage.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/php-wasm/compile/php-wasm-memory-storage/wasm_memory_storage.c b/packages/php-wasm/compile/php-wasm-memory-storage/wasm_memory_storage.c index a103e2a049..acf3fd54c4 100644 --- a/packages/php-wasm/compile/php-wasm-memory-storage/wasm_memory_storage.c +++ b/packages/php-wasm/compile/php-wasm-memory-storage/wasm_memory_storage.c @@ -17,6 +17,7 @@ #include #include +#include #include "php.h" #include "ext/standard/info.h" #include "Zend/zend_alloc.h" @@ -42,6 +43,7 @@ void* wasm_memory_storage_chunk_alloc(zend_mm_storage* storage, size_t size, siz if (posix_memalign(&ptr, alignment, size) == 0) { fprintf(stderr, "wasm_memory_storage_chunk_alloc: allocated: %p, size=%zu, alignment=%zu\n", ptr, size, alignment); + memset(ptr, 0, size); return ptr; } else { fprintf(stderr, "wasm_memory_storage_chunk_alloc: failed\n");