From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/av1dec: Always set ret before goto end
Date: Thu, 2 May 2024 15:31:35 -0300
Message-ID: <3191e450-5b13-4f77-b876-02d8e5fb7a42@gmail.com> (raw)
In-Reply-To: <AS8P250MB07446C8F1FD441049B6D33328F182@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
On 5/2/2024 6:48 AM, Andreas Rheinhardt wrote:
> Before 0f8763fbea4e8816cd54c2a481d4c048fec58394, av1_frame_ref()
> and update_reference_list() could fail and therefore needed to
> be checked, which incidentally set ret. This is no longer happening,
> leading to a potential use of an uninitialized value which is
> also the subject of Coverity ticket #1596605.
>
> Fix this by always setting ret before goto end; do not return
> some random ancient value.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Here is a different approach that uses the translation from 0 to EAGAIN.
>
> libavcodec/av1dec.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
> index 79a30a114d..75cc3fba48 100644
> --- a/libavcodec/av1dec.c
> +++ b/libavcodec/av1dec.c
> @@ -1333,12 +1333,15 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
>
> if (s->cur_frame.f) {
> ret = set_output_frame(avctx, frame);
> - if (ret < 0)
> + if (ret < 0) {
> av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n");
> + goto end;
> + }
> }
>
> s->raw_frame_header = NULL;
> i++;
> + ret = 0;
>
> goto end;
> }
> @@ -1439,17 +1442,20 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
>
> update_reference_list(avctx);
>
> - if (s->raw_frame_header->show_frame && s->cur_frame.f) {
> - ret = set_output_frame(avctx, frame);
> - if (ret < 0) {
> - av_log(avctx, AV_LOG_ERROR, "Set output frame error\n");
> - goto end;
> - }
> - }
> - raw_tile_group = NULL;
> + raw_tile_group = NULL;
> s->raw_frame_header = NULL;
> +
> if (show_frame) {
> + // cur_frame.f needn't exist due to skip_frame.
> + if (s->cur_frame.f) {
> + ret = set_output_frame(avctx, frame);
> + if (ret < 0) {
> + av_log(avctx, AV_LOG_ERROR, "Set output frame error\n");
> + goto end;
> + }
> + }
> i++;
> + ret = 0;
> goto end;
> }
> }
Should be ok.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2024-05-02 18:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-02 9:48 Andreas Rheinhardt
2024-05-02 18:31 ` James Almer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3191e450-5b13-4f77-b876-02d8e5fb7a42@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git