mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-14 12:19:43 +03:00
pdu.c: fix explicit NULL pointer dereference
Fixes CID 1459615 found by Coverity scan.
This commit is contained in:
1 parent
5cc5273867
commit
313a655a9a
1 file changed
+2
-2
@@ -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 */
|
||||
|
||||
Reference in new issue
Block a user