[FFmpeg-devel] [PATCH 2/2] avcodec/ffv1dec_template: wrap around in fltmap table

Michael Niedermayer michael at niedermayer.cc
Fri Mar 7 02:36:03 EET 2025


Avoids out of array access
Another solution may be choosen later if something else turns out to fit
naturally into the decoder. But for now dont crash

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/ffv1dec_template.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 37caacb758d..818f12f865d 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -225,11 +225,11 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, FFV1SliceContext *sc,
                 r += g;
             }
             if (sc->remap) {
-                r = sc->fltmap[0][r];
-                g = sc->fltmap[1][g];
-                b = sc->fltmap[2][b];
+                r = sc->fltmap[0][r & 0xFFFF];
+                g = sc->fltmap[1][g & 0xFFFF];
+                b = sc->fltmap[2][b & 0xFFFF];
                 if (transparency)
-                    a = sc->fltmap[3][a];
+                    a = sc->fltmap[3][a & 0xFFFF];
             }
 
             if (lbd)
-- 
2.48.1



More information about the ffmpeg-devel mailing list