mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
caps: fix race condition and memory leak in gst_static_caps_get
This was leaking the PtrArray from caps->priv, as set up by the other call to gst_caps_init. Also, the thread safety issue presented in the comment above was not taken care of anymore. We now zero the refcount again when publishing the structure. Fixes #661629.
This commit is contained in:
parent
acd905d78a
commit
221836f452
1 changed files with 3 additions and 4 deletions
|
@ -374,10 +374,9 @@ gst_static_caps_get (GstStaticCaps * static_caps)
|
|||
if (G_UNLIKELY (!gst_caps_from_string_inplace (&temp, string)))
|
||||
g_critical ("Could not convert static caps \"%s\"", string);
|
||||
|
||||
gst_caps_init (caps, sizeof (GstCaps));
|
||||
/* now copy stuff over to the real caps. */
|
||||
GST_CAPS_FLAGS (caps) = GST_CAPS_FLAGS (&temp);
|
||||
caps->priv = GST_CAPS_ARRAY (&temp);
|
||||
GST_MINI_OBJECT_REFCOUNT (&temp) = 0;
|
||||
memcpy (caps, &temp, sizeof (GstCaps));
|
||||
gst_caps_ref (caps);
|
||||
|
||||
GST_CAT_TRACE (GST_CAT_CAPS, "created %p", static_caps);
|
||||
done:
|
||||
|
|
Loading…
Reference in a new issue