filter-chain: fix reference counting issue

Fix a reference counting issue that resulted in
ladspa_handle's refcount being equal to the
sum of the refcounts of its descriptors.

This would result in a memory leak when a descriptor
is loaded more than once from the same handle.
This cannot happen because `ladspa_handle_list` is
not  populated by `ladspa_handle_load()`.
The next commit implements exactly that, so
the fix is applied before the change that
would introduce the problem.
This commit is contained in:
Barnabás Pőcze 2021-05-23 21:35:12 +02:00 committed by Wim Taymans
parent e9ba0899c2
commit a8a6def20f

View file

@ -844,6 +844,15 @@ static struct ladspa_descriptor *ladspa_descriptor_load(struct impl *impl,
spa_list_for_each(desc, &hndl->descriptor_list, link) { spa_list_for_each(desc, &hndl->descriptor_list, link) {
if (spa_streq(desc->label, label)) { if (spa_streq(desc->label, label)) {
desc->ref++; desc->ref++;
/*
* since ladspa_handle_load() increments the reference count of the handle,
* if the descriptor is found, then the handle's reference count
* has already been incremented to account for the descriptor,
* so we need to unref handle here since we're merely reusing
* thedescriptor, not creating a new one
*/
ladspa_handle_unref(hndl);
return desc; return desc;
} }
} }