CoAP: enable calling coap_get_payload with a NULL pointer

This commit is contained in:
Simon Duquennoy 2018-04-05 05:35:27 -07:00
parent 9a409bf264
commit 0df3c4fb90

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)