From 3a86ae027606cfcb270e18e3f2f830f557c57584 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 24 Jan 2022 09:51:10 +0100 Subject: [PATCH] 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. --- src/modules/module-client-node/client-node.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 688d8814a..dbfa91ea5 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -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);