From c82a1bc0ff4339a150cf4e8f8075d51ba49c50f8 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 12 Jul 2013 17:14:49 +0200 Subject: [PATCH] plugins: fix ref counting of GstVaapiVideoMemory allocator. Fix reference counting issue whereby gst_memory_init() does not hold an extra reference to the GstAllocator. So, there could be situations where the last instance of GstVaapiVideoAllocator gets released before a dangling GstVaapiVideoMemory object, thus possibly leading to a crash. --- gst/vaapi/gstvaapivideomemory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index 5409068..29bc2a9 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -218,7 +218,7 @@ gst_vaapi_video_memory_new(GstAllocator *base_allocator, return NULL; vip = &allocator->image_info; - gst_memory_init(&mem->parent_instance, 0, base_allocator, NULL, + gst_memory_init(&mem->parent_instance, 0, gst_object_ref(allocator), NULL, GST_VIDEO_INFO_SIZE(vip), 0, 0, GST_VIDEO_INFO_SIZE(vip)); mem->proxy = NULL; @@ -239,6 +239,7 @@ gst_vaapi_video_memory_free(GstVaapiVideoMemory *mem) gst_vaapi_object_replace(&mem->surface, NULL); gst_vaapi_object_replace(&mem->image, NULL); gst_vaapi_video_meta_unref(mem->meta); + gst_object_unref(GST_MEMORY_CAST(mem)->allocator); g_slice_free(GstVaapiVideoMemory, mem); } -- 2.7.4