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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3100>
This commit is contained in:
Jan Schmidt 2022-10-01 04:51:21 +10:00 committed by GStreamer Marge Bot
parent 6b7d4f74f2
commit eef76a9491

View file

@ -383,6 +383,13 @@ gst_xvimage_allocator_alloc (GstXvImageAllocator * allocator, gint im_format,
context->xv_port_id, im_format, NULL, padded_width, padded_height, context->xv_port_id, im_format, NULL, padded_width, padded_height,
&mem->SHMInfo); &mem->SHMInfo);
if (!mem->xvimage || error_caught) { 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); g_mutex_unlock (&context->lock);
/* Reset error flag */ /* Reset error flag */