From eef76a949171205c640b1f15ceac76e4da93dc79 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sat, 1 Oct 2022 04:51:21 +1000 Subject: [PATCH] xvimagesink: Don't leak XvShmImage If allocating an XvShmImage generates an X error, but still returns some allocated memory, make sure to free it so it doesn't leak. Part-of: --- .../gst-plugins-base/sys/xvimage/xvimageallocator.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subprojects/gst-plugins-base/sys/xvimage/xvimageallocator.c b/subprojects/gst-plugins-base/sys/xvimage/xvimageallocator.c index bf1f2bd9e4..a6d84325b8 100644 --- a/subprojects/gst-plugins-base/sys/xvimage/xvimageallocator.c +++ b/subprojects/gst-plugins-base/sys/xvimage/xvimageallocator.c @@ -383,6 +383,13 @@ gst_xvimage_allocator_alloc (GstXvImageAllocator * allocator, gint im_format, context->xv_port_id, im_format, NULL, padded_width, padded_height, &mem->SHMInfo); if (!mem->xvimage || error_caught) { + + /* If the memory was allocated, drop it */ + if (mem->xvimage) { + XFree (mem->xvimage); + mem->xvimage = NULL; + } + g_mutex_unlock (&context->lock); /* Reset error flag */