From 2176169257505d22021fc9a739c9f2090c514cb4 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 16 Oct 2025 17:47:13 +0300 Subject: check iteration on empty vectors --- include/conts/spvec.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/conts/spvec.h b/include/conts/spvec.h index 4fffb4a..d557fa8 100644 --- a/include/conts/spvec.h +++ b/include/conts/spvec.h @@ -193,6 +193,13 @@ static inline void SPVEC(shrink)(struct SPVEC_STRUCT *v, size_t n) static inline SPVEC_ITER SPVEC(begin)(struct SPVEC_STRUCT *v) { + if (v->n == 0) { + return (SPVEC_ITER) { + .i = 0, + .v = NULL + }; + } + return (SPVEC_ITER){ .i = 0, .v = SPVEC(at)(v, 0) -- cgit v1.2.3