mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 00:45:40 +03:00
coap_uri.c: Add NULL checks after coap_new_optlist() calls
This commit is contained in:
1 parent
dadb9a36f1
commit
ff6100f907
1 file changed
+12
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user