From 6fb2e671d1dcda940bdfdcfbbfcfe3e5bd7f896b Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Fri, 3 Nov 2017 14:55:33 +0100 Subject: [PATCH] async.c: added missing check for NULL in coap_free_async() Coverity scan has detected a possible NULL pointer being dereferenced before it is checked, see CID 1458391. --- src/async.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/async.c b/src/async.c index 74d8117b..3bbfcf1b 100644 --- a/src/async.c +++ b/src/async.c @@ -98,11 +98,15 @@ coap_remove_async(coap_context_t *context, coap_session_t *session, void coap_free_async(coap_async_state_t *s) { - if ( s->session ) - coap_session_release( s->session ); - if (s && (s->flags & COAP_ASYNC_RELEASE_DATA) != 0) - coap_free(s->appdata); - coap_free(s); + if (s) { + if (s->session) { + coap_session_release(s->session); + } + if ((s->flags & COAP_ASYNC_RELEASE_DATA) != 0) { + coap_free(s->appdata); + } + coap_free(s); + } } #else