mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
memory: don't unref allocator too soon
Unref the allocator *after* we have freed the memory. We also need to keep a ref to the allocator around because following the now freed memory would lead to crashes.
This commit is contained in:
parent
2ca0046934
commit
f37fc1d299
1 changed files with 7 additions and 3 deletions
|
@ -83,6 +83,8 @@ _gst_memory_copy (GstMemory * mem)
|
|||
static void
|
||||
_gst_memory_free (GstMemory * mem)
|
||||
{
|
||||
GstAllocator *allocator;
|
||||
|
||||
GST_CAT_DEBUG (GST_CAT_MEMORY, "free memory %p", mem);
|
||||
|
||||
if (mem->parent) {
|
||||
|
@ -90,8 +92,10 @@ _gst_memory_free (GstMemory * mem)
|
|||
gst_memory_unref (mem->parent);
|
||||
}
|
||||
|
||||
g_object_unref (mem->allocator);
|
||||
gst_allocator_free (mem->allocator, mem);
|
||||
allocator = mem->allocator;
|
||||
|
||||
gst_allocator_free (allocator, mem);
|
||||
gst_object_unref (allocator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +122,7 @@ gst_memory_init (GstMemory * mem, GstMemoryFlags flags,
|
|||
(GstMiniObjectCopyFunction) _gst_memory_copy, NULL,
|
||||
(GstMiniObjectFreeFunction) _gst_memory_free);
|
||||
|
||||
mem->allocator = g_object_ref (allocator);
|
||||
mem->allocator = gst_object_ref (allocator);
|
||||
if (parent) {
|
||||
gst_memory_lock (parent, GST_LOCK_FLAG_EXCLUSIVE);
|
||||
gst_memory_ref (parent);
|
||||
|
|
Loading…
Reference in a new issue