Merge pull request #411 from simonduq/fix/coap_get_payload

CoAP: enable calling coap_get_payload with a NULL pointer
This commit is contained in:
Simon Duquennoy 2018-04-13 15:49:47 +02:00 committed by GitHub
commit 472e119c5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1115,13 +1115,10 @@ coap_set_header_size1(coap_message_t *coap_pkt, uint32_t size)
int
coap_get_payload(coap_message_t *coap_pkt, const uint8_t **payload)
{
if(coap_pkt->payload) {
if(payload != NULL) {
*payload = coap_pkt->payload;
return coap_pkt->payload_len;
} else {
*payload = NULL;
return 0;
}
return coap_pkt->payload != NULL ? coap_pkt->payload_len : 0;
}
int
coap_set_payload(coap_message_t *coap_pkt, const void *payload, size_t length)