memory: Keep a reference to the allocator
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Sun, 24 Feb 2013 08:24:26 +0000 (09:24 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sun, 24 Feb 2013 08:46:01 +0000 (09:46 +0100)
Otherwise the allocator might get freed while it's still used
by the memory

gst/gstmemory.c

index 8101c91995aed2ad5c2cb784fc18c31c5473c768..afc652f9bc97570345e9f3c123f815bca5722d38 100644 (file)
@@ -90,6 +90,7 @@ _gst_memory_free (GstMemory * mem)
     gst_memory_unref (mem->parent);
   }
 
+  g_object_unref (mem->allocator);
   gst_allocator_free (mem->allocator, mem);
 }
 
@@ -117,7 +118,7 @@ gst_memory_init (GstMemory * mem, GstMemoryFlags flags,
       (GstMiniObjectCopyFunction) _gst_memory_copy, NULL,
       (GstMiniObjectFreeFunction) _gst_memory_free);
 
-  mem->allocator = allocator;
+  mem->allocator = g_object_ref (allocator);
   if (parent) {
     gst_memory_lock (parent, GST_LOCK_FLAG_EXCLUSIVE);
     gst_memory_ref (parent);