Skip to content

Commit

Permalink
net.c: memory leak in handle_request if error input
Browse files Browse the repository at this point in the history
coap_add_token() can error for multiple reasons when building the response
PDU - but then the response PDU is not deleted on error if it exists.

The PDU is now deleted on coap_add_token() error.
  • Loading branch information
mrdeep1 committed Aug 12, 2020
1 parent cbc3430 commit b3eacf2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -2363,10 +2363,11 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu
} else {
coap_delete_pdu(response);
}
response = NULL;
} else {
coap_log(LOG_WARNING, "cannot generate response\r\n");
coap_delete_pdu(response);
}
response = NULL;
} else {
if (coap_string_equal(uri_path, &coap_default_uri_wellknown)) {
/* request for .well-known/core */
Expand Down

0 comments on commit b3eacf2

Please sign in to comment.