changeset 9119:f3d87e34599f libavcodec

flacdec: Check for an inline header before calling metadata_parse().
author jbr
date Wed, 04 Mar 2009 00:52:18 +0000
parents f13d019e004a
children dfd80d6fabfe
files flacdec.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flacdec.c	Wed Mar 04 00:21:46 2009 +0000
+++ b/flacdec.c	Wed Mar 04 00:52:18 2009 +0000
@@ -224,14 +224,13 @@
  * the fLaC marker.
  * @param s the flac decoding context containing the gb bit reader used to
  *          parse metadata
- * @return 1 if some metadata was read, 0 if no fLaC marker was found
+ * @return non-zero if metadata is invalid
  */
 static int metadata_parse(FLACContext *s)
 {
     int i, metadata_last, metadata_type, metadata_size;
     int initial_pos= get_bits_count(&s->gb);
 
-    if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
         skip_bits_long(&s->gb, 32);
 
         do {
@@ -260,8 +259,6 @@
             }
         } while (!metadata_last);
 
-        return 1;
-    }
     return 0;
 }
 
@@ -642,8 +639,14 @@
 
     init_get_bits(&s->gb, buf, buf_size*8);
 
-    if (metadata_parse(s))
+    /* check for inline header */
+    if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
+        if (metadata_parse(s)) {
+            av_log(s->avctx, AV_LOG_ERROR, "invalid header\n");
+            return -1;
+        }
         goto end;
+    }
 
     tmp = show_bits(&s->gb, 16);
     if ((tmp & 0xFFFE) != 0xFFF8) {