memory leak in GstPlayer
Sorry, not set up to make an MR on this machine.
Found while valgrinding gtk4. The g_object_set call is not consuming the reference, so you have to free it.
commit 05a327a3625153ba6c9eca62d1b7ae01482b771d (HEAD -> main)
Author: Matthias Clasen <mclasen@redhat.com>
Date: Fri Aug 12 11:15:07 2022 -0400
gstplayer: Plug a memory leak
This was showing up as a memory leak in GTK's
gstreamer media backend:
40 bytes in 1 blocks are definitely lost in loss record 18,487 of 40,868
at 0x484586F: malloc (vg_replace_malloc.c:381)
by 0x50D5278: g_malloc (gmem.c:125)
by 0x50EDBA5: g_slice_alloc (gslice.c:1072)
by 0x50EFBCC: g_slice_alloc0 (gslice.c:1098)
by 0x51F2F45: g_type_create_instance (gtype.c:1911)
by 0x51DAE37: g_object_new_internal (gobject.c:2011)
by 0x51DC080: g_object_new_with_properties (gobject.c:2181)
by 0x51DCB20: g_object_new (gobject.c:1821)
by 0x9855F86: UnknownInlinedFun (gstplayer-wrapped-video-renderer.c:109)
by 0x9855F86: gst_player_new (gstplayer.c:579)
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c b/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c
index d11e7a62db..6f816d62ec 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/player/gstplayer.c
@@ -565,7 +565,6 @@ gst_player_new (GstPlayerVideoRenderer * video_renderer,
{
static GOnce once = G_ONCE_INIT;
GstPlayer *self;
- GstPlayerVideoRenderer *renderer = NULL;
g_once (&once, gst_player_init_once, NULL);
@@ -576,9 +575,11 @@ gst_player_new (GstPlayerVideoRenderer * video_renderer,
self->play = gst_play_new (NULL);
if (video_renderer != NULL) {
+ GstPlayerVideoRenderer *renderer;
renderer = gst_player_wrapped_video_renderer_new (video_renderer, self);
g_object_set (self->play, "video-renderer",
GST_PLAY_VIDEO_RENDERER (renderer), NULL);
+ g_object_unref (renderer);
}
if (signal_dispatcher != NULL) {