]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] kh_foreach should not be used with hash sets, it couses segfault on -O0 ... 2423/head
authorMikhail Galanin <mgalanin@mimecast.com>
Wed, 15 Aug 2018 14:09:36 +0000 (15:09 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Wed, 15 Aug 2018 14:09:36 +0000 (15:09 +0100)
src/libserver/events.c

index f62005b962ac771862ac98e8f49292ea73929898..bff35351f3e9a3b0de41f9e50ac931e26d642237 100644 (file)
@@ -309,14 +309,17 @@ void
 rspamd_session_cleanup (struct rspamd_async_session *session)
 {
        struct rspamd_async_event *ev;
-       gchar t;
+       int i;
 
        if (session == NULL) {
                msg_err ("session is NULL");
                return;
        }
 
-       kh_foreach (session->events, ev, t, {
+       for (i = kh_begin (session->events); i != kh_end (session->events); i ++) {
+               if (!kh_exist (session->events, i)) continue;
+               ev = kh_key (session->events, i);
+
                /* Call event's finalizer */
                msg_debug_session ("removed event on destroy: %p, subsystem: %s",
                                ev->user_data,
@@ -325,9 +328,7 @@ rspamd_session_cleanup (struct rspamd_async_session *session)
                if (ev->fin != NULL) {
                        ev->fin (ev->user_data);
                }
-       });
-
-       (void)t;
+       }
 
        kh_clear (rspamd_events_hash, session->events);
 }