Commit 16d0f7f408 for ffmpeg
commit 16d0f7f408ba47b4091a22109d4f22f5fd57820a
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Mon Sep 14 02:11:16 2026 +0200
avcodec/flashsv: require two bytes for a 15-bit pixel in decode_hybrid
Fixes: read of uninitialized memory
Fixes: YwR11Eee5EpN
Found-by: zhang xingxing
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 85540ed0d8..eb58e9ce09 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -85,6 +85,8 @@ static int decode_hybrid(const uint8_t *sptr, const uint8_t *sptr_end, uint8_t *
if (sptr >= sptr_end)
return AVERROR_INVALIDDATA;
if (*sptr & 0x80) {
+ if (sptr + 2 > sptr_end)
+ return AVERROR_INVALIDDATA;
/* 15-bit color */
unsigned c = AV_RB16(sptr) & ~0x8000;
unsigned b = c & 0x1F;