s4/messaging: do not deref NULL state (CID 1437973)
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 8 May 2019 03:58:08 +0000 (15:58 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 10 May 2019 01:15:17 +0000 (01:15 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/lib/messaging/messaging.c

index 6cf5853..1f27cf7 100644 (file)
@@ -578,6 +578,10 @@ static void imessaging_post_handler(struct tevent_context *ev,
        struct imessaging_post_state *state = talloc_get_type_abort(
                private_data, struct imessaging_post_state);
 
+       if (state == NULL) {
+               return;
+       }
+
        /*
         * In usecases like using messaging_client_init() with irpc processing
         * we may free the imessaging_context during the messaging handler.
@@ -594,10 +598,6 @@ static void imessaging_post_handler(struct tevent_context *ev,
        imessaging_dgm_recv(ev, state->buf, state->buf_len, NULL, 0,
                            state->msg_ctx);
 
-       if (state == NULL) {
-               return;
-       }
-
        state->busy_ref = NULL;
        TALLOC_FREE(state);
 }