]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: lib-event - Use for-loop in copying categories
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Aug 2020 08:39:59 +0000 (11:39 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Sep 2020 07:07:19 +0000 (07:07 +0000)
Avoids unsigned integer wrap

src/lib/lib-event.c

index 940508e391840ebe77bb791673ac981f7ef04e8f..b9b2e2f5b0af42404ca69aa8ad6e2ca65a7bb940 100644 (file)
@@ -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)