winegstreamer: Avoid releasing wg_allocator memory samples twice.

When the sample size is too small, we were releasing it from the memory,
but kept the next_sample pointer set. Later, when the transform removes
the sample from the allocator, its refcount was decremented one more
time, effectively leaking the sample.
This commit is contained in:
Rémi Bernon 2023-06-25 11:17:12 +02:00 committed by Alexandre Julliard
parent 762dda3837
commit 1b5ddc1e2f

View file

@ -196,9 +196,9 @@ static GstMemory *wg_allocator_alloc(GstAllocator *gst_allocator, gsize size,
pthread_mutex_lock(&allocator->mutex);
memory->sample = allocator->next_sample;
if (memory->sample && memory->sample->max_size >= size)
allocator->next_sample = NULL;
else
allocator->next_sample = NULL;
if (memory->sample && memory->sample->max_size < size)
release_memory_sample(allocator, memory, true);
list_add_tail(&allocator->memory_list, &memory->entry);