From ff6100f907d5dc677d029c6046aee1fc07282d3f Mon Sep 17 00:00:00 2001 From: Oblivionsage Date: Mon, 29 Dec 2025 17:24:39 +0100 Subject: [PATCH] coap_uri.c: Add NULL checks after coap_new_optlist() calls --- src/coap_uri.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/coap_uri.c b/src/coap_uri.c index 0cee50ea..75d6d9d6 100644 --- a/src/coap_uri.c +++ b/src/coap_uri.c @@ -782,6 +782,9 @@ coap_path_into_optlist(const uint8_t *s, size_t length, coap_option_num_t optnum default: /* add segment */ optlist = coap_new_optlist(optnum, s - p, p); + if (!optlist) { + return 0; + } coap_replace_percents(optlist); if (!coap_insert_optlist(optlist_chain, optlist)) { return 0; @@ -808,6 +811,9 @@ coap_path_into_optlist(const uint8_t *s, size_t length, coap_option_num_t optnum default: /* add segment */ optlist = coap_new_optlist(optnum, s - p, p); + if (!optlist) { + return 0; + } coap_replace_percents(optlist); if (!coap_insert_optlist(optlist_chain, optlist)) { return 0; @@ -851,6 +857,9 @@ coap_query_into_optlist(const uint8_t *s, size_t length, coap_option_num_t optnu if (*s == '&') { /* start of new query element */ /* add previous query element */ optlist = coap_new_optlist(optnum, s - p, p); + if (!optlist) { + return 0; + } coap_replace_percents(optlist); if (!coap_insert_optlist(optlist_chain, optlist)) { return 0; @@ -862,6 +871,9 @@ coap_query_into_optlist(const uint8_t *s, size_t length, coap_option_num_t optnu } /* add last query element */ optlist = coap_new_optlist(optnum, s - p, p); + if (!optlist) { + return 0; + } coap_replace_percents(optlist); if (!coap_insert_optlist(optlist_chain, optlist)) { return 0;