From: Nuo Mi <nuomi2021@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Nuo Mi <nuomi2021@gmail.com>, Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH] avcodec/vvcdec: fix undefined behaviours for derive_affine_mvc Date: Sun, 3 Mar 2024 22:04:47 +0800 Message-ID: <TYSPR06MB643345C354177A579BE899CBAA5C2@TYSPR06MB6433.apcprd06.prod.outlook.com> (raw) libavcodec/vvc/vvc_inter.c:823:18: runtime error: signed integer overflow: 1426128896 + 1426128896 cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior libavcodec/vvc/vvc_inter.c:823:18 Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/vvc/vvc_inter.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/vvc/vvc_inter.c b/libavcodec/vvc/vvc_inter.c index d5be32aa14..c5629f7f6f 100644 --- a/libavcodec/vvc/vvc_inter.c +++ b/libavcodec/vvc/vvc_inter.c @@ -817,10 +817,13 @@ static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvF const int vs = fc->ps.sps->vshift[1]; const MvField* mv2 = ff_vvc_get_mvf(fc, x0 + hs * sbw, y0 + vs * sbh); *mvc = *mv; - mvc->mv[0].x += mv2->mv[0].x; - mvc->mv[0].y += mv2->mv[0].y; - mvc->mv[1].x += mv2->mv[1].x; - mvc->mv[1].y += mv2->mv[1].y; + + // Due to different pred_flag, one of the motion vectors may have an invalid value. + // Cast them to an unsigned type to avoid undefined behavior. + mvc->mv[0].x += (unsigned int)mv2->mv[0].x; + mvc->mv[0].y += (unsigned int)mv2->mv[0].y; + mvc->mv[1].x += (unsigned int)mv2->mv[1].x; + mvc->mv[1].y += (unsigned int)mv2->mv[1].y; ff_vvc_round_mv(mvc->mv + 0, 0, 1); ff_vvc_round_mv(mvc->mv + 1, 0, 1); } -- 2.25.1 _______________________________________________ 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".
next reply other threads:[~2024-03-03 14:05 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-03 14:04 Nuo Mi [this message] 2024-03-04 12:42 ` Nuo Mi
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=TYSPR06MB643345C354177A579BE899CBAA5C2@TYSPR06MB6433.apcprd06.prod.outlook.com \ --to=nuomi2021@gmail.com \ --cc=andreas.rheinhardt@outlook.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