]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event_import*() - Allow importing duplicate data without using more memory
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Apr 2020 15:43:21 +0000 (18:43 +0300)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Tue, 4 Aug 2020 21:34:56 +0000 (21:34 +0000)
src/lib/lib-event.c

index 1950f5698f786ca755e18c9099e66d9800d52c2d..a89cfcdb9ad8ad71016801a28c296907be40290a 100644 (file)
@@ -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;