[FFmpeg-devel] [PATCH] lavf/ffmdec: return proper error code in ffm2_read_header()

Stefano Sabatini stefasab at gmail.com
Mon Sep 1 14:05:56 CEST 2014


---
 libavformat/ffmdec.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index f8fee2f..d74b6cf 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -238,8 +238,12 @@ static int ffm2_read_header(AVFormatContext *s)
     AVCodecContext *codec;
 
     ffm->packet_size = avio_rb32(pb);
-    if (ffm->packet_size != FFM_PACKET_SIZE)
+    if (ffm->packet_size != FFM_PACKET_SIZE) {
+        av_log(s, AV_LOG_ERROR, "Invalid packet size %d, expected was %d\n",
+               ffm->packet_size, FFM_PACKET_SIZE);
+        ret = AVERROR(EINVAL);
         goto fail;
+    }
     ffm->write_index = avio_rb64(pb);
     /* get also filesize */
     if (pb->seekable) {
@@ -266,9 +270,10 @@ static int ffm2_read_header(AVFormatContext *s)
             break;
         case MKBETAG('C', 'O', 'M', 'M'):
             st = avformat_new_stream(s, NULL);
-            if (!st)
+            if (!st) {
+                ret = AVERROR(ENOMEM);
                 goto fail;
-
+            }
             avpriv_set_pts_info(st, 64, 1, 1000000);
 
             codec = st->codec;
@@ -359,7 +364,7 @@ static int ffm2_read_header(AVFormatContext *s)
     return 0;
  fail:
     ffm_close(s);
-    return -1;
+    return ret;
 }
 
 static int ffm_read_header(AVFormatContext *s)
-- 
1.8.3.2



More information about the ffmpeg-devel mailing list