From bd85ecdd0ba00c15a2fa093e0896367ac0d48514 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 17 Aug 2022 14:21:54 +0200 Subject: Fix another potensial iter-bug in cvec binary search. --- include/stc/cvec.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 6b120ff0..fcf05c10 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -411,7 +411,8 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { if (i_eq((&raw), (&r))) return i1; } - i2.ref = NULL; return i2; // NB! + i2.ref = NULL; // NB! + return i2; } STC_DEF _cx_iter @@ -428,8 +429,9 @@ _cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, const _cx_raw raw, else if (c < 0) p2 = mid.ref; else i1.ref = mid.ref + 1; } + i2.ref = NULL; // NB! *lower_bound = i1.ref == i2.end ? i2 : i1; - i2.ref = NULL; return i2; // NB! + return i2; } STC_DEF int -- cgit v1.2.3