omxvideodec: fix buffer leak when eglimage setup fails

Can happen if gst_buffer_pool_acquire_buffer succeeds but
gst_buffer_n_memory (buffer) is not exactly 1.

In theory this should not happen because the decoder requests
EGLImage(RGBA) but better to fix any leak on corner cases.

https://bugzilla.gnome.org/show_bug.cgi?id=784365
This commit is contained in:
Julien Isorce 2017-06-29 23:17:26 +01:00
parent 5e6c3f170f
commit 7b114b131f

View file

@ -637,7 +637,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
GST_DEBUG_OBJECT (self, "Trying to allocate %d EGLImages", min);
for (i = 0; i < min; i++) {
GstBuffer *buffer;
GstBuffer *buffer = NULL;
GstMemory *mem;
GstGLMemoryEGL *gl_mem;
@ -646,6 +646,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
|| !(mem = gst_buffer_peek_memory (buffer, 0))
|| !GST_IS_GL_MEMORY_EGL_ALLOCATOR (mem->allocator)) {
GST_INFO_OBJECT (self, "Failed to allocated %d-th EGLImage", i);
gst_buffer_replace (&buffer, NULL);
g_list_free_full (buffers, (GDestroyNotify) gst_buffer_unref);
g_list_free (images);
buffers = NULL;