flac_parser: fix fifo ptr wrap check
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 22 Sep 2012 02:40:10 +0000 (04:40 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 22 Sep 2012 02:40:10 +0000 (04:40 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/flac_parser.c

index 17b96e2..e37ca64 100644 (file)
@@ -606,10 +606,11 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
 
         /* restore the state pre-padding */
         if (fpc->end_padded) {
 
         /* restore the state pre-padding */
         if (fpc->end_padded) {
+            int warp = fpc->fifo_buf->wptr - fpc->fifo_buf->buffer < MAX_FRAME_HEADER_SIZE;
             /* HACK: drain the tail of the fifo */
             fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
             fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
             /* HACK: drain the tail of the fifo */
             fpc->fifo_buf->wptr -= MAX_FRAME_HEADER_SIZE;
             fpc->fifo_buf->wndx -= MAX_FRAME_HEADER_SIZE;
-            if (fpc->fifo_buf->wptr < 0) {
+            if (warp) {
                 fpc->fifo_buf->wptr += fpc->fifo_buf->end -
                     fpc->fifo_buf->buffer;
             }
                 fpc->fifo_buf->wptr += fpc->fifo_buf->end -
                     fpc->fifo_buf->buffer;
             }