Skip to content

Commit

Permalink
glvideomixer: hold extra pad ref while calling parent
Browse files Browse the repository at this point in the history
Our subsequent cleanup needs a ref on the pad and calling the parent may
release the last reference and could cause a use-after-free.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1187>
  • Loading branch information
ystreet committed Jun 3, 2021
1 parent f647840 commit 3bbcfe9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/gl/gstglvideomixer.c
Expand Up @@ -881,7 +881,9 @@ gst_gl_video_mixer_release_pad (GstElement * element, GstPad * p)
/* we call the base class first as this will remove the pad from
* the aggregator, thus stopping misc callbacks from being called,
* one of which (process_textures) will recreate the vertex_buffer
* if it is destroyed */
* if it is destroyed. Calling the parent may release the last ref to the pad
* so we need to keep the pad alive for the follow up clean up */
gst_object_ref (pad);
GST_ELEMENT_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (element)))
->release_pad (element, p);

Expand All @@ -891,6 +893,7 @@ gst_gl_video_mixer_release_pad (GstElement * element, GstPad * p)
_del_buffer, &pad->vertex_buffer);
pad->vertex_buffer = 0;
}
gst_object_unref (pad);
}

static void
Expand Down

0 comments on commit 3bbcfe9

Please sign in to comment.