Skip to content

Commit a13b631

Browse files
author
Arto Kinnunen
committed
Fix error found by coverity
Fix 324966 Dereference before null check
1 parent 3c79829 commit a13b631

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/coap_message_handler.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2017, Arm Limited and affiliates.
2+
* Copyright (c) 2015-2019, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -192,14 +192,16 @@ static int8_t coap_rx_function(sn_coap_hdr_s *resp_ptr, sn_nsdl_addr_s *address_
192192
coap_transaction_t *this = NULL;
193193
(void)param;
194194

195-
if (resp_ptr->coap_status == COAP_STATUS_BUILDER_BLOCK_SENDING_DONE) {
196-
return 0;
195+
if (!resp_ptr || !address_ptr) {
196+
return -1;
197197
}
198198

199199
tr_warn("transaction was not handled %d", resp_ptr->msg_id);
200-
if (!resp_ptr || !address_ptr) {
201-
return -1;
200+
201+
if (resp_ptr->coap_status == COAP_STATUS_BUILDER_BLOCK_SENDING_DONE) {
202+
return 0;
202203
}
204+
203205
if (resp_ptr->token_ptr) {
204206
this = transaction_find_client_by_token(resp_ptr->token_ptr, resp_ptr->token_len, address_ptr->addr_ptr, address_ptr->port);
205207
}

0 commit comments

Comments
 (0)