miniobject: don't modify memory if it's clearly not a valid miniobject
authorTim-Philipp Müller <tim@centricular.com>
Sat, 15 Jul 2017 10:54:18 +0000 (11:54 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 15 Jul 2017 10:57:43 +0000 (11:57 +0100)
Add back function guard that checks the refcount in a read-only
operation first, and bail out without modifying the passed-in
memory if it's clearly not a valid mini object. Otherwise we
probably cause more harm than good. We keep the second sanity
check based on the 'real refcount' at the time of the unref
around for now too.

https://bugzilla.gnome.org/show_bug.cgi?id=784383

gst/gstminiobject.c

index b42fb98..fcba49d 100644 (file)
@@ -429,6 +429,7 @@ gst_mini_object_unref (GstMiniObject * mini_object)
   gint old_refcount, new_refcount;
 
   g_return_if_fail (mini_object != NULL);
+  g_return_if_fail (GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0);
 
   old_refcount = g_atomic_int_add (&mini_object->refcount, -1);
   new_refcount = old_refcount - 1;