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 <james.hilliard1@gmail.com>
This commit is contained in:
James Hilliard 2022-07-24 20:57:42 -06:00 committed by Wim Taymans
parent 3579857a64
commit 4c43d39a64

View file

@ -281,8 +281,10 @@ static int do_negotiate(struct pw_impl_link *this)
/* find a common format for the ports */ /* find a common format for the ports */
if ((res = pw_context_find_format(context, if ((res = pw_context_find_format(context,
output, input, NULL, 0, NULL, output, input, NULL, 0, NULL,
&format, &b, &error)) < 0) &format, &b, &error)) < 0) {
format = NULL;
goto error; goto error;
}
format = spa_pod_copy(format); format = spa_pod_copy(format);
spa_pod_fixate(format); spa_pod_fixate(format);