pool: fix deallocation of video pools.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 12 Jul 2013 13:01:01 +0000 (15:01 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 12 Jul 2013 13:01:01 +0000 (15:01 +0200)
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

index 23912e6..4dc523b 100644 (file)
@@ -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);
 }