client-node: handle mix init errors better

Make sure we mark the port invalid when we can't allocate an id
for it. Also check that the id does not exceed the max amount of
areas we have allocated and release resources correctly.
This commit is contained in:
Wim Taymans 2022-01-24 09:51:10 +01:00
parent 7e387d842b
commit 3a86ae0276

View file

@ -1390,8 +1390,15 @@ static int port_init_mix(void *data, struct pw_impl_port_mix *mix)
return -ENOMEM;
mix->id = pw_map_insert_new(&impl->io_map, NULL);
if (mix->id == SPA_ID_INVALID)
if (mix->id == SPA_ID_INVALID) {
m->valid = false;
return -errno;
}
if (mix->id > MAX_AREAS) {
pw_map_remove(&impl->io_map, mix->id);
m->valid = false;
return -ENOMEM;
}
mix->io = SPA_PTROFF(impl->io_areas->map->ptr,
mix->id * sizeof(struct spa_io_buffers), void);