modules: handle allocation errors

This commit is contained in:
Wim Taymans 2026-05-01 12:29:54 +02:00
parent a55546c9df
commit 6f6b58785e
5 changed files with 29 additions and 1 deletions

View file

@ -100,6 +100,8 @@ struct tunnel {
struct spa_hook module_listener;
};
static void tunnel_free(struct tunnel *t);
static struct tunnel *tunnel_new(struct impl *impl, const struct tunnel_info *info)
{
struct tunnel *t;
@ -112,6 +114,11 @@ static struct tunnel *tunnel_new(struct impl *impl, const struct tunnel_info *in
t->info.mode = strdup(info->mode);
spa_list_append(&impl->tunnel_list, &t->link);
if (t->info.name == NULL || t->info.mode == NULL) {
tunnel_free(t);
errno = ENOMEM;
return NULL;
}
return t;
}