From 04e26a7b9fca3d0d945f3d7640f5b92fa96c8247 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 27 May 2023 00:55:22 +0900 Subject: [PATCH] [set] Check for 0 count correctly I don't know what I was thinking when I checked for 0 count for resizing the set. Attempting to add/remove 0 elements results in adding/removing 4G elements. Oops. --- libs/util/set.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/util/set.c b/libs/util/set.c index e391583a6..71f1a82e9 100644 --- a/libs/util/set.c +++ b/libs/util/set.c @@ -194,7 +194,10 @@ _set_remove (set_t *set, unsigned x) static inline void _set_add_range (set_t *set, unsigned start, unsigned count) { - if (!count || start + count > set->size) { + if (!count) { + return; + } + if (start + count > set->size) { set_expand (set, start + count); } unsigned end = start + count - 1; @@ -216,7 +219,10 @@ _set_add_range (set_t *set, unsigned start, unsigned count) static inline void _set_remove_range (set_t *set, unsigned start, unsigned count) { - if (!count || start >= set->size) { + if (!count) { + return; + } + if (start >= set->size) { return; } if (start + count > set->size) {