v4l2: fix memory leak for dyn resolution change

if resolution changed, old input state will not unref before
new state overwrite self->input_state

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9479>
This commit is contained in:
Qian Hu (胡骞) 2025-08-01 16:33:39 +08:00 committed by GStreamer Marge Bot
parent a374bd51fb
commit a626f74872

View File

@ -281,7 +281,7 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder,
if (self->input_state && !dyn_resolution) {
if (compatible_caps (self, state->caps)) {
GST_DEBUG_OBJECT (self, "Compatible caps");
goto done;
return TRUE;
}
gst_video_codec_state_unref (self->input_state);
self->input_state = NULL;
@ -320,13 +320,16 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder,
if (!dyn_resolution)
ret = gst_v4l2_object_set_format (self->v4l2output, state->caps, &error);
if (ret)
self->input_state = gst_video_codec_state_ref (state);
else
if (!ret) {
gst_v4l2_error (self, &error);
return FALSE;
}
done:
return ret;
if (self->input_state)
gst_video_codec_state_unref (self->input_state);
self->input_state = gst_video_codec_state_ref (state);
return TRUE;
}
static gboolean