diff mbox

[FFmpeg-devel] lavc/zmbvenc: Do not left-shift negative values

Message ID CAB0OVGoWSc_fmmSf5QNLhB2=+tXXn8Ld3k1DdbKCzd+_=vABcQ@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos June 30, 2019, 11:47 p.m. UTC
Hi!

Attached patch fixes the only (remaining) issue I see with the sample
of ticket #7980.

Please comment, Carl Eugen

Comments

Michael Niedermayer July 1, 2019, 6:30 p.m. UTC | #1
On Mon, Jul 01, 2019 at 01:47:46AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes the only (remaining) issue I see with the sample
> of ticket #7980.
> 
> Please comment, Carl Eugen

>  zmbvenc.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 39d38ac46b445460b0f27aec16e70ed176fa7cfe  0001-lavc-zmbvenc-Do-not-left-shift-negative-values.patch
> From e6ff8f43c0d92733335b52290e18231438ce7770 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Mon, 1 Jul 2019 01:45:36 +0200
> Subject: [PATCH] lavc/zmbvenc: Do not left-shift negative values.
> 
> Fixes the following ubsan errors with the sample from ticket #7980:
> libavcodec/zmbvenc.c:243:29: runtime error: left shift of negative value -4
> libavcodec/zmbvenc.c:244:28: runtime error: left shift of negative value -2
> ---
>  libavcodec/zmbvenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

LGTM

thx

[...]
Tomas Härdin July 1, 2019, 7:06 p.m. UTC | #2
mån 2019-07-01 klockan 01:47 +0200 skrev Carl Eugen Hoyos:
> Hi!
> 
> Attached patch fixes the only (remaining) issue I see with the sample
> of ticket #7980.
> 
> Please comment, Carl Eugen

Looks OK to me

/Tomas
Carl Eugen Hoyos Aug. 11, 2019, 9:45 p.m. UTC | #3
Am Mo., 1. Juli 2019 um 20:41 Uhr schrieb Michael Niedermayer
<michael@niedermayer.cc>:
>
> On Mon, Jul 01, 2019 at 01:47:46AM +0200, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch fixes the only (remaining) issue I see with the sample
> > of ticket #7980.
> >
> > Please comment, Carl Eugen
>
> >  zmbvenc.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 39d38ac46b445460b0f27aec16e70ed176fa7cfe  0001-lavc-zmbvenc-Do-not-left-shift-negative-values.patch
> > From e6ff8f43c0d92733335b52290e18231438ce7770 Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> > Date: Mon, 1 Jul 2019 01:45:36 +0200
> > Subject: [PATCH] lavc/zmbvenc: Do not left-shift negative values.
> >
> > Fixes the following ubsan errors with the sample from ticket #7980:
> > libavcodec/zmbvenc.c:243:29: runtime error: left shift of negative value -4
> > libavcodec/zmbvenc.c:244:28: runtime error: left shift of negative value -2
> > ---
> >  libavcodec/zmbvenc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
>
> LGTM

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From e6ff8f43c0d92733335b52290e18231438ce7770 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 1 Jul 2019 01:45:36 +0200
Subject: [PATCH] lavc/zmbvenc: Do not left-shift negative values.

Fixes the following ubsan errors with the sample from ticket #7980:
libavcodec/zmbvenc.c:243:29: runtime error: left shift of negative value -4
libavcodec/zmbvenc.c:244:28: runtime error: left shift of negative value -2
---
 libavcodec/zmbvenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 48871758e0..0e22ce687f 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -240,8 +240,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
                 tprev = prev + x * c->bypp;
 
                 zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored);
-                mv[0] = (mx << 1) | !!xored;
-                mv[1] = my << 1;
+                mv[0] = (mx * 2) | !!xored;
+                mv[1] = my * 2;
                 tprev += mx * c->bypp + my * c->pstride;
                 if(xored){
                     for(j = 0; j < bh2; j++){
-- 
2.22.0