avrndec: calculate true_height only when used.
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 13 Nov 2012 21:02:46 +0000 (22:02 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 13 Nov 2012 21:03:21 +0000 (22:03 +0100)
Fixes division by 0

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/avrndec.c

index 95c81c8..361b668 100644 (file)
@@ -78,12 +78,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
     AVFrame *p = &a->frame;
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
-    int true_height    = buf_size / (2*avctx->width);
-    int y, ret;
+    int y, ret, true_height;
 
     if(a->is_mjpeg)
         return ff_mjpeg_decode_frame(avctx, data, data_size, avpkt);
 
+    true_height    = buf_size / (2*avctx->width);
     if(p->data[0])
         avctx->release_buffer(avctx, p);