]> git.sesse.net Git - ffmpeg/commitdiff
diracdec: fix maximum quantization index checks
authorRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 13 Jul 2016 22:40:06 +0000 (23:40 +0100)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 13 Jul 2016 22:40:06 +0000 (23:40 +0100)
Found by Coverity, fixes CID1363961 and CID1363962

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/diracdec.c

index 9275c509cb22e0ba90bbed082458b42f1a7a87f7..dc42a42d86056fd2614fbd155f8066ab9db5b346 100644 (file)
@@ -513,7 +513,7 @@ static inline void codeblock(DiracContext *s, SubBand *b,
         b->quant = quant;
     }
 
-    if (b->quant > DIRAC_MAX_QUANT_INDEX) {
+    if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
         av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", b->quant);
         b->quant = 0;
         return;
@@ -703,7 +703,7 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
     uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
     int x, y;
 
-    if (quant > DIRAC_MAX_QUANT_INDEX) {
+    if (quant > (DIRAC_MAX_QUANT_INDEX - 1)) {
         av_log(s->avctx, AV_LOG_ERROR, "Unsupported quant %d\n", quant);
         return;
     }