From 6649bdef39dbcb7825a0bc63f9f8a373100c5d7a Mon Sep 17 00:00:00 2001 From: kkrentz Date: Tue, 7 Jun 2022 15:55:12 +0200 Subject: [PATCH] net.c: fix null pointer exception --- src/net.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/net.c b/src/net.c index 468846e2..77ecfc3c 100644 --- a/src/net.c +++ b/src/net.c @@ -2875,6 +2875,11 @@ handle_request(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu ? COAP_MESSAGE_ACK : COAP_MESSAGE_NON, 0, pdu->mid, coap_session_max_pdu_size(session)); + if (!response) { + coap_log(LOG_ERR, "could not create response PDU\n"); + resp = 500; + goto fail_response; + } #ifndef WITHOUT_ASYNC /* If handling a separate response, need CON, not ACK response */ if (async && pdu->type == COAP_MESSAGE_CON)