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:
parent
20945c6329
commit
8b3ef2c346
5 changed files with 7 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue