From: Mengkejiergeli Ba Date: Thu, 17 Feb 2022 07:12:52 +0000 (+0800) Subject: msdk: Fix unchecked return values X-Git-Tag: 1.22.0~2356 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1090c152c90d86de762ff7438646e9ea6d077f6;p=platform%2Fupstream%2Fgstreamer.git msdk: Fix unchecked return values There are several calls of gst_video_info_from_caps and gst_video_frame_copy without checks for the returned values. This patch adds all necessary function return checks. Part-of: --- diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c index 748ab1f..58aef3d 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c @@ -882,7 +882,12 @@ gst_msdkdec_finish_task (GstMsdkDec * thiz, MsdkDecTask * task) GST_MINI_OBJECT_FLAG_SET (surface->buf, GST_MINI_OBJECT_FLAG_LOCKABLE); frame->output_buffer = gst_buffer_ref (surface->buf); } else { - gst_video_frame_copy (&surface->copy, &surface->data); + if (!gst_video_frame_copy (&surface->copy, &surface->data)) { + GST_ERROR_OBJECT (thiz, "Failed to copy surface data"); + gst_video_frame_unmap (&surface->copy); + gst_video_frame_unmap (&surface->data); + return GST_FLOW_ERROR; + } frame->output_buffer = gst_buffer_ref (surface->copy.buffer); unmap_frame (thiz, surface); } @@ -1321,7 +1326,12 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) gst_video_decoder_get_output_state (GST_VIDEO_DECODER (thiz)); if (output_state) { if (output_state->allocation_caps) { - gst_video_info_from_caps (&alloc_info, output_state->allocation_caps); + if (!gst_video_info_from_caps (&alloc_info, + output_state->allocation_caps)) { + GST_ERROR_OBJECT (thiz, "Failed to get video info from caps"); + flow = GST_FLOW_ERROR; + goto error; + } /* Check whether we need complete reset for dynamic resolution change */ if (thiz->param.mfx.FrameInfo.Width > @@ -1727,7 +1737,10 @@ gst_msdkdec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query) min_buffers, max_buffers); if (!gst_buffer_pool_set_config (pool, pool_config)) goto error_set_config; - gst_video_info_from_caps (&thiz->non_msdk_pool_info, pool_caps); + if (!gst_video_info_from_caps (&thiz->non_msdk_pool_info, pool_caps)) { + GST_ERROR_OBJECT (thiz, "Failed to get video info from caps"); + return FALSE; + } /* update width and height with actual negotiated values */ output_state = diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkvpp.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkvpp.c index 3bdc982..b409c2e 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkvpp.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkvpp.c @@ -1300,8 +1300,10 @@ gst_msdkvpp_set_caps (GstBaseTransform * trans, GstCaps * caps, gst_caps_get_features (out_caps, 0))) thiz->need_vpp = 1; - gst_video_info_from_caps (&in_info, caps); - gst_video_info_from_caps (&out_info, out_caps); + if (!gst_video_info_from_caps (&in_info, caps)) + goto error_no_video_info; + if (!gst_video_info_from_caps (&out_info, out_caps)) + goto error_no_video_info; if (!gst_video_info_is_equal (&in_info, &thiz->sinkpad_info)) sinkpad_info_changed = TRUE; @@ -1347,6 +1349,10 @@ gst_msdkvpp_set_caps (GstBaseTransform * trans, GstCaps * caps, } return TRUE; + +error_no_video_info: + GST_ERROR_OBJECT (thiz, "Failed to get video info from caps"); + return FALSE; } static gboolean