From 9226891bb9f174cb90e32d697d7333d59c97f87d Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 13 Sep 2026 21:14:11 +0100 Subject: [PATCH] wpArrayClear memsets members to 0 --- CHANGELOG.md | 1 + src/base/array/array.c | 1 + src/base/array/array.h | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b2238..2b975a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Switched to using `wpMiscUtilsRotl64` in `xorshift` - Remove all uses of names starting with underscore +- Ensure `wpArrayClear` memsets members to 0 ## [2.4.0] - 2026-08-30 diff --git a/src/base/array/array.c b/src/base/array/array.c index bc133dd..d056697 100644 --- a/src/base/array/array.c +++ b/src/base/array/array.c @@ -214,6 +214,7 @@ void arrayClear(WpArray array, u64 item_size) { WpArrayHeader *header = arrayHeader(array); header->count = 0; + memset(array, 0, header->capacity * header->item_size); } u64 arrayCalcAllocSize(u64 capacity, u64 item_size) { diff --git a/src/base/array/array.h b/src/base/array/array.h index 6bdeaa5..5c952d9 100644 --- a/src/base/array/array.h +++ b/src/base/array/array.h @@ -200,18 +200,18 @@ void arrayAppendCapped(WpArray array, void *value, u64 item_size); void arrayExtendCappend(WpArray dst, const WpArray src, u64 item_size); void arrayCopyCapped(WpArray dst, const WpArray src, u64 item_size); WpArray arrayAppendAlloc(const WpAllocator *allocator, WpArray array, void *value, - WpArrayInitFlags flags, u64 item_size); + WpArrayInitFlags flags, u64 item_size); WpArray arrayExtendAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, - WpArrayInitFlags flags, u64 item_size); + WpArrayInitFlags flags, u64 item_size); WpArray arrayCopyAlloc(const WpAllocator *allocator, WpArray dst, const WpArray src, - WpArrayInitFlags flags, u64 item_size); + WpArrayInitFlags flags, u64 item_size); void *arrayPop(WpArray array, u64 item_size); void arrayClear(WpArray array, u64 item_size); u64 arrayCalcAllocSize(u64 capacity, u64 item_size); WpArray arrayAllocCapacity(const WpAllocator *allocator, u64 capacity, WpArrayInitFlags flags, - u64 item_size); + u64 item_size); WpArray arrayFromPreallocatedBuffer(void *buffer, u64 buffer_size, WpArrayInitFlags flags, - u64 item_size); + u64 item_size); void arrayDealloc(const WpAllocator *allocator, WpArray *array, u64 item_size); #ifdef WP_PLATFORM_CPP