changeset 9121:7f11c330c5d6 libavcodec

flacdec: When there is not enough data to read the next header block, reset the bitstream reader instead of skipping backwards.
author jbr
date Wed, 04 Mar 2009 01:08:26 +0000
parents dfd80d6fabfe
children 0613e9b5514c
files flacdec.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flacdec.c	Wed Mar 04 00:53:04 2009 +0000
+++ b/flacdec.c	Wed Mar 04 01:08:26 2009 +0000
@@ -229,7 +229,6 @@
 static int metadata_parse(FLACContext *s)
 {
     int i, metadata_last, metadata_type, metadata_size;
-    int initial_pos= get_bits_count(&s->gb);
 
     skip_bits_long(&s->gb, 32);
 
@@ -239,7 +238,8 @@
         metadata_size = get_bits_long(&s->gb, 24);
 
         if (get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits) {
-            skip_bits_long(&s->gb, initial_pos - get_bits_count(&s->gb));
+            /* need more data. reset the bitstream reader and return. */
+            init_get_bits(&s->gb, s->gb.buffer, s->gb.size_in_bits);
             break;
         }