Fix bug 6796 - Deleting an event context on shutdown can cause smbd to crash.
authorJeremy Allison <jra@samba.org>
Fri, 9 Oct 2009 19:50:26 +0000 (12:50 -0700)
committerKarolin Seeger <kseeger@samba.org>
Mon, 12 Oct 2009 08:49:43 +0000 (10:49 +0200)
Sync's tevent signal code with 3.5.x tree.
Protects against ev pointer being NULL.

Jeremy

tevent/tevent_signal.c

index 0ca2a2760b0338112a1f3ebaa9cceb1ec857cabc..ab170a66cf75f38c5785e720e3c7ceff83419e79 100644 (file)
@@ -90,18 +90,12 @@ static void tevent_common_signal_handler(int signum)
        SIG_INCREMENT(sig_state->signal_count[signum]);
        SIG_INCREMENT(sig_state->got_signal);
 
-       if (sig_state->sig_handlers[signum] != NULL) {
-               ev = sig_state->sig_handlers[signum]->se->event_ctx;
-               /* doesn't matter if this pipe overflows */
-               res = write(ev->pipe_fds[1], &c, 1);
-       }
-
        /* Write to each unique event context. */
        for (sl = sig_state->sig_handlers[signum]; sl; sl = sl->next) {
-               if (sl->se->event_ctx != ev) {
+               if (sl->se->event_ctx && sl->se->event_ctx != ev) {
+                       ev = sl->se->event_ctx;
                        /* doesn't matter if this pipe overflows */
                        res = write(ev->pipe_fds[1], &c, 1);
-                       ev = sl->se->event_ctx;
                }
        }