proxy: guard coap_proxy_get_add_list_entry() against two NULL sessions

`coap_proxy_get_add_list_entry(incoming, ongoing, ...)` dereferences `ongoing->context` when `incoming == NULL`. Current in-tree callers always pass exactly one non-NULL session, but the function is a public-ish internal helper and a future caller passing both NULL would dereference NULL immediately. cppcheck flags exactly this (`nullPointer` on `ongoing`).

This adds an explicit early `return NULL` when both arguments are NULL - defensive only, no behavior change for existing callers.

Signed-off-by: warter666 <121139223+Warterkk@users.noreply.github.com>
This commit is contained in:
Guancheng Wang authored and Jon Shallow committed 2026-09-19 12:25:46 +02:00
1 parent f6b20b0d3d
commit 53e1bcaeba
1 file changed
+2
+2
View File
@@ -381,6 +381,8 @@ static coap_proxy_entry_t *
coap_proxy_get_add_list_entry(coap_session_t *incoming, coap_session_t *ongoing,
coap_uri_t uri, coap_proxy_server_list_t *server_list,
int allow_add) {
if (!incoming && !ongoing)
return NULL;
coap_context_t *context = incoming ? incoming->context : ongoing->context;
coap_proxy_entry_t *proxy_list = context->proxy_list;
size_t proxy_list_count = context->proxy_list_count;