]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: lib-event - Assert-crash if attempting to use NULL passthrough event
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 4 Oct 2021 11:42:14 +0000 (14:42 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 5 Oct 2021 09:57:30 +0000 (09:57 +0000)
Fixes also complaints from static analyzer.

src/lib/lib-event.c

index d0afec37402b000a670d983832a926e5b482f57c..b39983ceaf95fa3bee2b03fdd49b203464a0ca4b 100644 (file)
@@ -87,6 +87,7 @@ event_category_find_internal(const char *name);
 
 static struct event *last_passthrough_event(void)
 {
+       i_assert(event_last_passthrough != NULL);
        return container_of(event_last_passthrough,
                            struct event, event_passthrough);
 }
@@ -472,8 +473,10 @@ void event_unref(struct event **_event)
 
        event_call_callbacks_noargs(event, EVENT_CALLBACK_TYPE_FREE);
 
-       if (last_passthrough_event() == event)
-               event_last_passthrough = NULL;
+       if (event_last_passthrough != NULL) {
+               if (last_passthrough_event() == event)
+                       event_last_passthrough = NULL;
+       }
        if (event->log_prefix_from_system_pool)
                i_free(event->log_prefix);
        i_free(event->sending_name);