coap_uri.c: Add NULL checks after coap_new_optlist() calls

This commit is contained in:
Oblivionsage authored and Jon Shallow committed 2025-12-29 16:46:42 +00:00
1 parent dadb9a36f1
commit ff6100f907
1 file changed
+12
+12
View File
@@ -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;