glfilter: Only add parent meta if inbuf != outbuf
authorPiotr Brzeziński <piotr@centricular.com>
Mon, 9 Oct 2023 12:48:35 +0000 (14:48 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 10 Oct 2023 09:13:15 +0000 (10:13 +0100)
This was causing a memory leak in cases like `gltestsrc ! gltransformation scale-x=0.5 ! glimagesink`.
Parent meta was being added in assumption that those buffers are different, which was not the case here,
creating a reference loop and never freeing the buffer.

Co-authored-by: Matthew Waters <matthew@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5453>

subprojects/gst-plugins-base/gst-libs/gst/gl/gstglfilter.c

index 54bb050..895d77a 100644 (file)
@@ -1038,7 +1038,8 @@ gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
    * buffer meta to hold one reference of inbuf, this can avoid this
    * buffer sync problem.
    */
-  gst_buffer_add_parent_buffer_meta (outbuf, inbuf);
+  if (inbuf != outbuf)
+    gst_buffer_add_parent_buffer_meta (outbuf, inbuf);
 
   return ret ? GST_FLOW_OK : GST_FLOW_ERROR;
 }