defensive: NULL-check calloc results before dereferencing

Five sites allocated with calloc() and dereferenced the result on the
very next line. Under OOM the module would have segfaulted instead of
degrading. Each site now bails (or sends a Canceled D-Bus error, in
the agent path) when the allocation fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-04-29 18:27:44 +07:00
commit 8b3ef2c346
5 changed files with 7 additions and 0 deletions

View file

@ -63,6 +63,7 @@ iwd_manager_listener_add(Iwd_Manager *m, Iwd_Manager_Cb cb, void *data)
{
if (!m || !cb) return;
Listener *l = calloc(1, sizeof(*l));
if (!l) return;
l->cb = cb; l->data = data;
m->listeners = eina_list_append(m->listeners, l);
}