mpegvideo_motion: Handle edge emulation even without unrestricted_mv
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Nov 2013 15:11:42 +0000 (16:11 +0100)
committerSebastian Ramacher <sramacher@debian.org>
Sat, 24 Sep 2016 13:23:39 +0000 (13:23 +0000)
Fix out of bounds read.

Bug-Id: 959
Found by: F4B3CD@STARLAB and Agostino Sarubbo
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
(cherry picked from commit 136f55207521f0b03194ef5b55ba70f1635d6aee)
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Gbp-Pq: Name mpegvideo_motion-Handle-edge-emulation-even-without-.patch

libavcodec/mpegvideo_motion.c

index f33db341deb37966e61f97230c37f0d7d4c39b34..a3cba98e5e9a6c386c137e2fbe15cdc5df10fefe 100644 (file)
@@ -209,17 +209,14 @@ static inline int hpel_motion(MpegEncContext *s,
         dxy |= (motion_y & 1) << 1;
     src += src_y * s->linesize + src_x;
 
-    if (s->unrestricted_mv) {
-        if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||
-            (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {
-            s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src,
-                                     s->linesize, s->linesize,
-                                     9, 9,
-                                     src_x, src_y, s->h_edge_pos,
-                                     s->v_edge_pos);
-            src = s->edge_emu_buffer;
-            emu = 1;
-        }
+    if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 8, 0) ||
+        (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y & 1) - 8, 0)) {
+        s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src,
+                                 s->linesize, s->linesize,
+                                 9, 9, src_x, src_y,
+                                 s->h_edge_pos, s->v_edge_pos);
+        src = s->edge_emu_buffer;
+        emu = 1;
     }
     pix_op[dxy](dest, src, s->linesize, 8);
     return emu;