From: Aki Tuomi Date: Thu, 13 Aug 2020 08:39:59 +0000 (+0300) Subject: lib: lib-event - Use for-loop in copying categories X-Git-Tag: 2.3.13~213 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20765bf4763e1ce80af35e5fc74b406d63cef39c;p=thirdparty%2Fdovecot%2Fcore.git lib: lib-event - Use for-loop in copying categories Avoids unsigned integer wrap --- diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index 940508e391..b9b2e2f5b0 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -142,8 +142,8 @@ void event_copy_categories(struct event *to, struct event *from) { unsigned int cat_count; struct event_category *const *categories = event_get_categories(from, &cat_count); - while (cat_count-- > 0) - event_add_category(to, categories[cat_count]); + for (unsigned int i = 1; i <= cat_count; i++) + event_add_category(to, categories[cat_count-i]); } void event_copy_fields(struct event *to, struct event *from)