From c2e19fed01152f693ad23dda7dc5582005f5b4e4 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 29 Sep 2021 23:29:57 +0200 Subject: [PATCH] Fix issue in IT_INSERT (Wrong behavior if IT==END) --- m-array.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/m-array.h b/m-array.h index abcc41b9..e76cf7c4 100644 --- a/m-array.h +++ b/m-array.h @@ -769,8 +769,9 @@ M_C(name, _insert)(array_t a, it_t it, type const x) \ { \ M_ASSERT (it != NULL && a == it->array); \ - M_C(name, _push_at)(a, it->index + 1, x); \ - it->index ++; \ + size_t index = M_C(name, _end_p)(it) ? 0 : it->index+1; \ + M_C(name, _push_at)(a, index, x); \ + it->index = index; \ } \ , /* End of INIT_SET */ ) \ \