v4l2: fix use after free when handling events

The sink_event parent function may consume the event so we shouldn't use
it after having calling it.
This commit is contained in:
Guillaume Desmottes 2019-04-16 14:35:06 +05:30
parent 4040c01083
commit 443c16e1e3
3 changed files with 9 additions and 6 deletions

View file

@ -968,12 +968,13 @@ gst_v4l2_transform_sink_event (GstBaseTransform * trans, GstEvent * event)
{
GstV4l2Transform *self = GST_V4L2_TRANSFORM (trans);
gboolean ret;
GstEventType type = GST_EVENT_TYPE (event);
/* Nothing to flush in passthrough */
if (gst_base_transform_is_passthrough (trans))
return GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (self, "flush start");
gst_v4l2_object_unlock (self->v4l2output);
@ -985,7 +986,7 @@ gst_v4l2_transform_sink_event (GstBaseTransform * trans, GstEvent * event)
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->sink_event (trans, event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_STOP:
/* Buffer should be back now */
GST_DEBUG_OBJECT (self, "flush stop");

View file

@ -872,8 +872,9 @@ gst_v4l2_video_dec_sink_event (GstVideoDecoder * decoder, GstEvent * event)
{
GstV4l2VideoDec *self = GST_V4L2_VIDEO_DEC (decoder);
gboolean ret;
GstEventType type = GST_EVENT_TYPE (event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (self, "flush start");
gst_v4l2_object_unlock (self->v4l2output);
@ -885,7 +886,7 @@ gst_v4l2_video_dec_sink_event (GstVideoDecoder * decoder, GstEvent * event)
ret = GST_VIDEO_DECODER_CLASS (parent_class)->sink_event (decoder, event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_START:
/* The processing thread should stop now, wait for it */
gst_pad_stop_task (decoder->srcpad);

View file

@ -973,8 +973,9 @@ gst_v4l2_video_enc_sink_event (GstVideoEncoder * encoder, GstEvent * event)
{
GstV4l2VideoEnc *self = GST_V4L2_VIDEO_ENC (encoder);
gboolean ret;
GstEventType type = GST_EVENT_TYPE (event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (self, "flush start");
gst_v4l2_object_unlock (self->v4l2output);
@ -986,7 +987,7 @@ gst_v4l2_video_enc_sink_event (GstVideoEncoder * encoder, GstEvent * event)
ret = GST_VIDEO_ENCODER_CLASS (parent_class)->sink_event (encoder, event);
switch (GST_EVENT_TYPE (event)) {
switch (type) {
case GST_EVENT_FLUSH_START:
gst_pad_stop_task (encoder->srcpad);
GST_DEBUG_OBJECT (self, "flush start done");