From 1781e5937a6e200e3627d482bee6ccb919444568 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 16 Oct 2024 07:49:11 +0200 Subject: Fix bounds check --- include/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/array.h b/include/array.h index e3ce3e8..0853c2d 100644 --- a/include/array.h +++ b/include/array.h @@ -45,7 +45,7 @@ _mlib_array_hdr(void *p, ptrdiff_t align) #define array_extend(p, xs, n) \ do { \ _mlib_arr_hdr_t *hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ - if (hdr->len + (n) <= hdr->cap) { \ + if (hdr->len + (n) >= hdr->cap) { \ (p) = array_resz((p), stdc_bit_ceil((size_t)hdr->len + (n))); \ hdr = _mlib_array_hdr((p), alignof(typeof(*(p)))); \ } \ -- cgit v1.2.3