Skip to content

Commit d0eec80

Browse files
author
Tero Heinonen
authored
Fix error case memory leak (ARMmbed#1537)
When panid query was received with missing TLV, scan_ptr was set to NULL without pointer free. In some cases, that caused memory leak.
1 parent da9860f commit d0eec80

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/6LoWPAN/Thread/thread_management_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ static int thread_management_server_panid_query_cb(int8_t service_id, uint8_t so
857857
this->scan_ptr->timer = eventOS_timeout_ms(thread_panid_scan_timeout_cb, 500, this);// Delay for the confirm response message
858858
if (!this->scan_ptr->timer) {
859859
ns_dyn_mem_free(this->scan_ptr);
860+
this->scan_ptr = NULL;
860861
response_code = COAP_MSG_CODE_RESPONSE_INTERNAL_SERVER_ERROR;
861862
goto error_exit;
862863
}
@@ -875,7 +876,6 @@ static int thread_management_server_panid_query_cb(int8_t service_id, uint8_t so
875876
}
876877
return -1;
877878
error_exit:
878-
this->scan_ptr = NULL;
879879
if (request_ptr->msg_type == COAP_MSG_TYPE_CONFIRMABLE ){
880880
coap_service_response_send(this->coap_service_id, COAP_REQUEST_OPTIONS_NONE, request_ptr, response_code, COAP_CT_OCTET_STREAM, NULL, 0);
881881
return 0;

0 commit comments

Comments
 (0)