[PATCH] Coverity fixes.

Jeremy Allison jra at samba.org
Fri Nov 9 23:10:55 UTC 2018


On Sat, Nov 10, 2018 at 12:05:31AM +0100, Stefan Metzmacher via samba-technical wrote:
> Am 10.11.18 um 00:02 schrieb Stefan Metzmacher via samba-technical:
> > Am 09.11.18 um 22:25 schrieb Jeremy Allison via samba-technical:
> >> Subject: [PATCH 1/2] s4: lib: messaging. Fix dead code. Coverity CID: 1437973
> >>
> >> Signed-off-by: Jeremy Allison <jra at samba.org>
> >> ---
> >>  source4/lib/messaging/messaging.c | 4 ----
> >>  1 file changed, 4 deletions(-)
> >>
> >> diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
> >> index 935951f3fba..dada565d1be 100644
> >> --- a/source4/lib/messaging/messaging.c
> >> +++ b/source4/lib/messaging/messaging.c
> >> @@ -470,10 +470,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);
> >>  }
> > 
> > This is wrong! See a08ab2940051ae47ce71149087a24d060227ef19
> > 
> > imessaging_post_state_destructor() may set state = NULL,
> > via the state->busy_ref pointer.
> 
> Fixing Coverity or compiler warnings is *much* harder than
> it sometimes seems and they need very careful review!

Well not *all* of them :-). That one was particularly
nasty, as it involved a destructor reaching into local
varaible state and modifying it.

That's pretty rare (or at least I'd hope so). Most
of them are much more straightforward than that.



More information about the samba-technical mailing list