From 20765bf4763e1ce80af35e5fc74b406d63cef39c Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 13 Aug 2020 11:39:59 +0300 Subject: [PATCH] lib: lib-event - Use for-loop in copying categories Avoids unsigned integer wrap --- src/lib/lib-event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.47.3