diff mbox series

[FFmpeg-devel,3/5] avcodec/pixlet: Fix log(0) check

Message ID 20200613112345.13515-3-michael@niedermayer.cc
State Accepted
Commit bd0f81526d3f4c23ecd0a399829103be2445c011
Headers show
Series [FFmpeg-devel,1/5] avcodec/iff: Fix off by x error | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer June 13, 2020, 11:23 a.m. UTC
Fixes: passing zero to clz(), which is not a valid argument
Fixes: 23337/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-5179131989065728

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/pixlet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index 7b068b1ce5..78f571cd5f 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -221,7 +221,7 @@  static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
     length = 25 - nbits;
 
     while (i < size) {
-        if (state >> 8 != -3)
+        if (((state >> 8) + 3) & 0xFFFFFFF)
             value = ff_clz((state >> 8) + 3) ^ 0x1F;
         else
             value = -1;