From b072b9b3a0bc17023feb2073090bc2db5bce9d72 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 29 Apr 2018 12:17:45 +0300 Subject: [PATCH] lib: event_add_str() - Ignore calls when value is NULL 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/lib-event.c b/src/lib/lib-event.c index a5e10b9db8..b1b6483fd1 100644 --- a/src/lib/lib-event.c +++ b/src/lib/lib-event.c @@ -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);