From ac757551050ea328b42ea701c4328ecbd7d279c6 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 12 Jul 2013 15:01:01 +0200 Subject: [PATCH] pool: fix deallocation of video pools. The queue of free objects to used was deallocated with g_queue_free_full(). However, this convenience function shall only be used if the original queue was allocated with g_queue_new(). This caused memory corruption, eventually leading to a crash. The correct solution is to pair the g_queue_init() with the corresponding g_queue_clear(), while iterating over all free objects to deallocate them. --- gst-libs/gst/vaapi/gstvaapivideopool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapivideopool.c b/gst-libs/gst/vaapi/gstvaapivideopool.c index 23912e6198..4dc523b6c5 100644 --- a/gst-libs/gst/vaapi/gstvaapivideopool.c +++ b/gst-libs/gst/vaapi/gstvaapivideopool.c @@ -70,7 +70,8 @@ void gst_vaapi_video_pool_finalize(GstVaapiVideoPool *pool) { g_list_free_full(pool->used_objects, gst_vaapi_object_unref); - g_queue_free_full(&pool->free_objects, gst_vaapi_object_unref); + g_queue_foreach(&pool->free_objects, (GFunc)gst_vaapi_object_unref, NULL); + g_queue_clear(&pool->free_objects); gst_vaapi_display_replace(&pool->display, NULL); }