Skip to content

Commit

Permalink
lib: event_add_str() - Ignore calls when value is NULL
Browse files Browse the repository at this point in the history
Alternative could be to assert-crash instead. But perhaps this makes it
easier to use and avoids unnecessary assert-crashes?
  • Loading branch information
sirainen committed May 21, 2018
1 parent 29f222d commit b072b9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/lib-event.c
Expand Up @@ -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);
Expand Down

0 comments on commit b072b9b

Please sign in to comment.