From c591f7a8aeae71b7de95832bfed4ef1626e1f4f5 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 29 Oct 2023 20:27:49 +1100 Subject: [PATCH] [common] vector: assert if the vector itemSize <= 0 --- common/src/vector.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/vector.c b/common/src/vector.c index 95740436..681df9e0 100644 --- a/common/src/vector.c +++ b/common/src/vector.c @@ -66,12 +66,15 @@ bool vector_create(Vector * vector, size_t itemSize, size_t capacity) void vector_destroy(Vector * vector) { free(vector->data); + vector->data = NULL; vector->capacity = 0; vector->itemSize = 0; } void * vector_push(Vector * vector, void * item) { + DEBUG_ASSERT(vector->itemSize > 0 && "itemSize should not be zero"); + if (vector->size >= vector->capacity) { size_t newCapacity = vector->capacity < 4 ? 8 : vector->capacity * 2;