lavc/zmbvenc: Do not left-shift negative values.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Sun, 30 Jun 2019 23:45:36 +0000 (01:45 +0200)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Sun, 11 Aug 2019 21:43:14 +0000 (23:43 +0200)
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

index 4887175..0e22ce6 100644 (file)
@@ -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++){