]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event_add_str() - Ignore calls when value is NULL
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 29 Apr 2018 09:17:45 +0000 (12:17 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 7 Jun 2018 07:30:57 +0000 (10:30 +0300)
Alternative could be to assert-crash instead. But perhaps this makes it
easier to use and avoids unnecessary assert-crashes?

src/lib/lib-event.c

index a5e10b9db8d40075193f1e6eef76e19eea82ed9e..b1b6483fd12b1df0ab3df719780711db2293fc06 100644 (file)
@@ -392,6 +392,11 @@ event_add_str(struct event *event, const char *key, const char *value)
 {
        struct event_field *field;
 
+       if (value == NULL) {
+               /* silently ignoring is perhaps better than assert-crashing? */
+               return event;
+       }
+
        field = event_get_field(event, key);
        field->value_type = EVENT_FIELD_VALUE_TYPE_STR;
        i_zero(&field->value);