[pulseaudio-discuss] [PATCH 1/2] memblock: Detect block ID collisions in pa_memimport_get
David Henningsson
david.henningsson at canonical.com
Fri Dec 5 02:54:38 PST 2014
Make sure we don't hand out the wrong block, in case we have the
same block ID in different SHM segments.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/pulsecore/memblock.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index f8b008f..ca24dec 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -1017,6 +1017,11 @@ pa_memblock* pa_memimport_get(pa_memimport *i, uint32_t block_id, uint32_t shm_i
pa_mutex_lock(i->mutex);
if ((b = pa_hashmap_get(i->blocks, PA_UINT32_TO_PTR(block_id)))) {
+ if (b->type != PA_MEMBLOCK_IMPORTED || b->per_type.imported.segment->memory.id != shm_id) {
+ pa_log("Cannot import memory due to to block ID collision (block %d, shm id %d)!", (int) block_id, (int) shm_id);
+ b = NULL;
+ goto finish;
+ }
pa_memblock_ref(b);
goto finish;
}
--
1.9.1
More information about the pulseaudio-discuss
mailing list