From: Timo Sirainen Date: Tue, 28 Apr 2020 15:43:21 +0000 (+0300) Subject: lib: event_import*() - Allow importing duplicate data without using more memory X-Git-Tag: 2.3.13~434 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f78e3f8bfbbe5a1c1de968855c965a941c7c60d5;p=thirdparty%2Fdovecot%2Fcore.git lib: event_import*() - Allow importing duplicate data without using more memory --- diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index 1950f5698f..a89cfcdb9a 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -1121,7 +1121,8 @@ bool event_import_unescaped(struct event *event, const char *const *args, } if (!array_is_created(&event->categories)) p_array_init(&event->categories, event->pool, 4); - array_push_back(&event->categories, &category); + if (!event_find_category(event, category)) + array_push_back(&event->categories, &category); break; } case EVENT_CODE_TV_LAST_SENT: @@ -1173,6 +1174,11 @@ bool event_import_unescaped(struct event *event, const char *const *args, } break; case EVENT_CODE_FIELD_STR: + if (field->value_type == EVENT_FIELD_VALUE_TYPE_STR && + null_strcmp(field->value.str, *args) == 0) { + /* already identical value */ + break; + } field->value_type = EVENT_FIELD_VALUE_TYPE_STR; field->value.str = p_strdup(event->pool, *args); break;