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.
This commit is contained in:
Olaf Bergmann committed 2017-11-03 14:55:33 +01:00
1 parent 1f51ba7636
commit 6fb2e671d1
1 file changed
+9 -5
+9 -5
View File
@@ -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