From 4c43d39a64a91d2a1c1fbd5954f49c7b4acd2f89 Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Sun, 24 Jul 2022 20:57:42 -0600 Subject: [PATCH] impl-link: only free format in do_negotiate if copied Fixes: ==716== Invalid free() / delete / delete[] / realloc() ==716== at 0x4846DED: free (vg_replace_malloc.c:872) ==716== by 0x48ABF37: do_negotiate (impl-link.c:425) ==716== by 0x48ACBEF: check_states (impl-link.c:701) ==716== by 0x48DB34B: process_work_queue (work-queue.c:87) ==716== by 0x4F8B2B3: source_event_func (loop.c:591) ==716== by 0x4F8D03F: loop_iterate (loop.c:430) ==716== by 0x48B1A4B: pw_main_loop_run (main-loop.c:148) ==716== by 0x10962F: main (pipewire.c:131) ==716== Address 0x1ffeffd520 is on thread 1's stack ==716== 4112 bytes below stack pointer ==716== Signed-off-by: James Hilliard --- src/pipewire/impl-link.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 095f1eabc..3a7f66d40 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -281,8 +281,10 @@ static int do_negotiate(struct pw_impl_link *this) /* find a common format for the ports */ if ((res = pw_context_find_format(context, output, input, NULL, 0, NULL, - &format, &b, &error)) < 0) + &format, &b, &error)) < 0) { + format = NULL; goto error; + } format = spa_pod_copy(format); spa_pod_fixate(format);