aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-16 07:49:11 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-16 07:49:11 +0200
commit1781e5937a6e200e3627d482bee6ccb919444568 (patch)
tree1fd7f53e35941512a6cb461f8d07d2a3f9066520
parent327f33ef24cfca7c5c4bb8c00f82a19514dc0346 (diff)
Fix bounds check
-rw-r--r--include/array.h2
1 files changed, 1 insertions, 1 deletions
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)))); \
} \