mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-12 11:40:39 +03:00
net.c: fix memory leak for query in handle_request
The storage for query was not released when coap_add_token() has failed. As the query is used only if successful, the storage allocation is moved downwards to improve handling of error cases. This fixes CID 1483550.
This commit is contained in:
1 parent
48dc4538ce
commit
c98cc237b3
1 file changed
+2
-2
@@ -2242,8 +2242,6 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu
|
||||
h = resource->handler[pdu->code - 1];
|
||||
|
||||
if (h) {
|
||||
coap_string_t *query = coap_get_query(pdu);
|
||||
int owns_query = 1;
|
||||
coap_log(LOG_DEBUG, "call custom handler for resource '%*.*s'\n",
|
||||
(int)resource->uri_path->length, (int)resource->uri_path->length,
|
||||
resource->uri_path->s);
|
||||
@@ -2259,6 +2257,8 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu
|
||||
coap_opt_iterator_t opt_iter;
|
||||
coap_opt_t *observe = NULL;
|
||||
int observe_action = COAP_OBSERVE_CANCEL;
|
||||
coap_string_t *query = coap_get_query(pdu);
|
||||
int owns_query = 1;
|
||||
|
||||
/* check for Observe option RFC7641 and RFC8132 */
|
||||
if (resource->observable &&
|
||||
|
||||
Reference in new issue
Block a user