Skip to content

Commit

Permalink
coap-server.c: check if data is present in PUT request
Browse files Browse the repository at this point in the history
This change change fixes coverity CID 1472105.
  • Loading branch information
obgm committed Jul 31, 2018
1 parent 57ee5eb commit 1cef78e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/coap-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,12 @@ hnd_put(coap_context_t *ctx UNUSED_PARAM,
response->code = COAP_RESPONSE_CODE(204);
}

coap_get_data (request, &size, &data);
if (dynamic_entry[i].value) {
coap_delete_string(dynamic_entry[i].value);
dynamic_entry[i].value = NULL;
}

if (size > 0) {
if (coap_get_data(request, &size, &data) && (size > 0)) {
dynamic_entry[i].value = coap_new_string(size);
memcpy (dynamic_entry[i].value->s, data, size);
dynamic_entry[i].value->length = size;
Expand Down

0 comments on commit 1cef78e

Please sign in to comment.