From 41af3304f021ffe319d3a50d439457bec17983a3 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Thu, 1 Dec 2016 14:50:16 +0100 Subject: [PATCH] net.c: explicitly clear pointer to free'd storage Static code analysis tools have incorrectly reported a memory leak in function handle_request(). To avoid this false positive, the variable response is explicitly set to NULL after releasing the memory with coap_delete_pdu(). --- src/net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net.c b/src/net.c index c4aa43d6..c66f571d 100644 --- a/src/net.c +++ b/src/net.c @@ -1425,6 +1425,7 @@ handle_request(coap_context_t *context, coap_queue_t *node) { warn("cannot send response for transaction %u\n", node->id); } coap_delete_pdu(response); + response = NULL; return; } @@ -1509,6 +1510,7 @@ handle_request(coap_context_t *context, coap_queue_t *node) { } } coap_delete_pdu(response); + response = NULL; } else { warn("cannot generate response\r\n"); } @@ -1528,7 +1530,10 @@ handle_request(coap_context_t *context, coap_queue_t *node) { } } coap_delete_pdu(response); - } + response = NULL; + } + + assert(response == NULL); } static inline void