v4l2allocator: Fix memory leak with dmabuf

This patch fixes a memory leak that is caused if the dmabuf file
descriptor dup fails.  Previously, _cleanup_failed_alloc() would
not unref the memory because mems_allocated had not yet been
incremented.

https://bugzilla.gnome.org/show_bug.cgi?id=784302
This commit is contained in:
Matt Fischer 2017-06-27 18:20:17 -05:00 committed by Nicolas Dufresne
parent 83987b5037
commit e8a4678738

View file

@ -888,6 +888,8 @@ gst_v4l2_allocator_alloc_dmabuf (GstV4l2Allocator * allocator,
gst_object_ref (allocator);
}
group->mems_allocated++;
g_assert (gst_is_v4l2_memory (group->mem[i]));
mem = (GstV4l2Memory *) group->mem[i];
@ -901,7 +903,6 @@ gst_v4l2_allocator_alloc_dmabuf (GstV4l2Allocator * allocator,
GST_V4L2_MEMORY_QUARK, mem, (GDestroyNotify) gst_memory_unref);
group->mem[i] = dma_mem;
group->mems_allocated++;
}
gst_v4l2_allocator_reset_size (allocator, group);