From 33801fe0951c0829f2ed7a35c3451bb7a9d86027 Mon Sep 17 00:00:00 2001 From: Shinya Saito Date: Wed, 1 Nov 2017 18:05:26 +0900 Subject: waylandsink: Fix memory leak of shm allocator. gst_allocator_find() needs gst_object_unref() after usage. https://bugzilla.gnome.org/show_bug.cgi?id=790042 --- ext/wayland/gstwaylandsink.c | 12 ++++++++---- ext/wayland/wlwindow.c | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 46a710fd0..dc5a06409 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -455,18 +455,20 @@ gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps) GstBufferPool *pool = NULL; GstStructure *structure; gsize size = sink->video_info.size; + GstAllocator *alloc; pool = gst_video_buffer_pool_new (); structure = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (structure, caps, size, 2, 0); - gst_buffer_pool_config_set_allocator (structure, gst_wl_shm_allocator_get (), - NULL); + alloc = gst_wl_shm_allocator_get (); + gst_buffer_pool_config_set_allocator (structure, alloc, NULL); if (!gst_buffer_pool_set_config (pool, structure)) { g_object_unref (pool); pool = NULL; } + g_object_unref (alloc); return pool; } @@ -530,6 +532,7 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) GstCaps *caps; GstBufferPool *pool = NULL; gboolean need_pool; + GstAllocator *alloc; gst_query_parse_allocation (query, &caps, &need_pool); @@ -540,9 +543,10 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0); g_object_unref (pool); } - - gst_query_add_allocation_param (query, gst_wl_shm_allocator_get (), NULL); + alloc = gst_wl_shm_allocator_get (); + gst_query_add_allocation_param (query, alloc, NULL); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); + g_object_unref (alloc); return TRUE; } diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c index d08ed87c2..c64c77a0d 100644 --- a/ext/wayland/wlwindow.c +++ b/ext/wayland/wlwindow.c @@ -332,6 +332,7 @@ gst_wl_window_update_borders (GstWlWindow * window) GstBuffer *buf; struct wl_buffer *wlbuf; GstWlBuffer *gwlbuf; + GstAllocator *alloc; if (window->no_border_update) return; @@ -354,7 +355,9 @@ gst_wl_window_update_borders (GstWlWindow * window) /* draw the area_subsurface */ gst_video_info_set_format (&info, format, width, height); - buf = gst_buffer_new_allocate (gst_wl_shm_allocator_get (), info.size, NULL); + alloc = gst_wl_shm_allocator_get (); + + buf = gst_buffer_new_allocate (alloc, info.size, NULL); gst_buffer_memset (buf, 0, 0, info.size); wlbuf = gst_wl_shm_memory_construct_wl_buffer (gst_buffer_peek_memory (buf, 0), @@ -365,6 +368,7 @@ gst_wl_window_update_borders (GstWlWindow * window) /* at this point, the GstWlBuffer keeps the buffer * alive and will free it on wl_buffer::release */ gst_buffer_unref (buf); + g_object_unref (alloc); } void -- cgit v1.2.1