Skip to content

Commit

Permalink
Coverity: Fix CID 1382579, CID 1502425, CID 1594471 and CID 1594475
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jul 11, 2024
1 parent 7d5e5f3 commit aa46177
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/coap-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ hnd_proxy_uri(coap_resource_t *resource COAP_UNUSED,
size_t total;
coap_binary_t *body_data = NULL;
const uint8_t *data;
coap_pdu_t *pdu;
coap_pdu_t *pdu = NULL;
coap_optlist_t *optlist = NULL;
coap_opt_t *option;
coap_bin_const_t token = coap_pdu_get_token(request);
Expand Down Expand Up @@ -1093,7 +1093,6 @@ hnd_proxy_uri(coap_resource_t *resource COAP_UNUSED,
if (!coap_add_token(pdu, token.length, token.s)) {
coap_log_debug("cannot add token to proxy request\n");
coap_pdu_set_code(response, COAP_RESPONSE_CODE_INTERNAL_ERROR);
coap_delete_pdu(pdu);
goto cleanup;
}

Expand Down Expand Up @@ -1166,6 +1165,7 @@ hnd_proxy_uri(coap_resource_t *resource COAP_UNUSED,
* Do not update with response code (hence empty ACK) as will be sending
* separate response when response comes back from upstream server
*/
pdu = NULL;
goto cleanup;
} else {
/* TODO http & https */
Expand All @@ -1175,6 +1175,7 @@ hnd_proxy_uri(coap_resource_t *resource COAP_UNUSED,
coap_delete_string(uri_path);
coap_delete_string(uri_query);
coap_delete_binary(body_data);
coap_delete_pdu(pdu);
}

#endif /* SERVER_CAN_PROXY */
Expand Down
1 change: 1 addition & 0 deletions src/coap_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -3675,6 +3675,7 @@ coap_handle_response_get_block(coap_context_t *context,
STATE_TOKEN_BASE(coap_decode_var_bytes8(rcvd->actual_token.s,
rcvd->actual_token.length));

coap_lock_check_locked(context);
memset(&block, 0, sizeof(block));
#if COAP_Q_BLOCK_SUPPORT
memset(&qblock, 0, sizeof(qblock));
Expand Down
2 changes: 1 addition & 1 deletion src/coap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ coap_new_context(const coap_address_t *listen_addr) {
memset(c, 0, sizeof(coap_context_t));

coap_lock_init(c);
coap_lock_lock(c, return NULL);
coap_lock_lock(c, coap_free_type(COAP_CONTEXT, c); return NULL);
#ifdef COAP_EPOLL_SUPPORT
c->epfd = epoll_create1(0);
if (c->epfd == -1) {
Expand Down
2 changes: 2 additions & 0 deletions src/coap_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,8 @@ coap_notify_observers(coap_context_t *context, coap_resource_t *r,
coap_tick_t now;
coap_session_t *obs_session;

coap_lock_check_locked(context);

if (r->observable && (r->dirty || r->partiallydirty)) {
r->partiallydirty = 0;

Expand Down

0 comments on commit aa46177

Please sign in to comment.