v4l2: videodec: Ensure object is inactive on failure
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Fri, 14 Apr 2023 13:51:39 +0000 (09:51 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 2 May 2023 14:42:43 +0000 (14:42 +0000)
Sprinkle stop() calls in error case to guaranty that the capture object
is inactive on failure. Not doing so could allow some code to be called
in unexpected (and possibly undefined) conditions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4525>

subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c

index 541fd72..2883605 100644 (file)
@@ -685,13 +685,16 @@ gst_v4l2_video_dec_setup_capture (GstVideoDecoder * decoder)
 not_negotiated:
   GST_ERROR_OBJECT (self, "not negotiated");
   gst_v4l2_error (self, &error);
+  gst_v4l2_object_stop (self->v4l2capture);
   return GST_FLOW_NOT_NEGOTIATED;
 activate_failed:
   GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
       (_("Failed to allocate required memory.")),
       ("Buffer pool activation failed"));
+  gst_v4l2_object_stop (self->v4l2capture);
   return GST_FLOW_ERROR;
 flushing:
+  gst_v4l2_object_stop (self->v4l2capture);
   return GST_FLOW_FLUSHING;
 }