security: fix missing NULL check after strdup in module-raop-discover

Memory Safety: Medium

strdup() can return NULL on allocation failure. The return value was
used without checking, which would cause a NULL pointer dereference
(crash) when the name is later compared with spa_streq(). Add a NULL
check and free the partially-allocated struct on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-27 16:12:47 +02:00
parent 15c32c66f0
commit ca0fa1e4e1

View file

@ -147,6 +147,10 @@ static struct tunnel *tunnel_new(struct impl *impl, const char *name)
return NULL; return NULL;
t->name = strdup(name); t->name = strdup(name);
if (t->name == NULL) {
free(t);
return NULL;
}
spa_list_append(&impl->tunnel_list, &t->link); spa_list_append(&impl->tunnel_list, &t->link);
return t; return t;