pdu.c: fix explicit NULL pointer dereference

Fixes CID 1459615 found by Coverity scan.
This commit is contained in:
Olaf Bergmann committed 2017-11-03 13:37:56 +01:00
1 parent 5cc5273867
commit 313a655a9a
1 file changed
+2 -2
+2 -2
View File
@@ -108,7 +108,7 @@ coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size) {
pdu->pbuf = pbuf_alloc(PBUF_TRANSPORT, size + pdu->max_hdr_size, PBUF_RAM);
if (pdu->pbuf == NULL) {
coap_free_type(COAP_PDU, pdu);
pdu = NULL;
return NULL;
}
pdu->token = pdu->pbuf->payload + pdu->max_hdr_size;
#else /* WITH_LWIP */
@@ -116,7 +116,7 @@ coap_pdu_init(uint8_t type, uint8_t code, uint16_t tid, size_t size) {
buf = coap_malloc_type(COAP_PDU_BUF, pdu->alloc_size + pdu->max_hdr_size);
if (buf == NULL) {
coap_free_type(COAP_PDU, pdu);
pdu = NULL;
return NULL;
}
pdu->token = buf + pdu->max_hdr_size;
#endif /* WITH_LWIP */