Hi,

attached patch fixes crashes with ffm files containing an extradata_size setting, but without extradata.

Such files are created by the ffm muxer, e.g. with for the asv1 codec.

Best regards,
Andreas
>From b3da247975db1bc0dd86805f2830aa0b718fd355 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Sun, 8 Mar 2015 23:24:40 +0100
Subject: [PATCH 4/8] ffmdec: don't set extradata_size without allocating
 extradata

When extradata_size is not 0, but extradata is NULL, code trying to use
extradata crashes.

If there is any extradata, extradata_size is set in ff_get_extradata.

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 libavformat/ffmdec.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 2459691..35e4c03 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -260,7 +260,7 @@ static int ffm2_read_header(AVFormatContext *s)
     AVStream *st;
     AVIOContext *pb = s->pb;
     AVCodecContext *codec = NULL;
-    int ret;
+    int ret, old_extradata_size;
     int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
     AVCodec *enc;
     char *buffer;
@@ -411,6 +411,7 @@ static int ffm2_read_header(AVFormatContext *s)
                 ret = AVERROR(EINVAL);
                 goto fail;
             }
+            old_extradata_size = codec->extradata_size;
             buffer = av_malloc(size);
             if (!buffer) {
                 ret = AVERROR(ENOMEM);
@@ -418,6 +419,11 @@ static int ffm2_read_header(AVFormatContext *s)
             }
             avio_get_str(pb, INT_MAX, buffer, size);
             av_set_options_string(codec, buffer, "=", ",");
+            if (codec->extradata_size != old_extradata_size) {
+                av_log(s, AV_LOG_WARNING, "ignoring extradata_size=%d in S2VI chunk\n",
+                       codec->extradata_size);
+                codec->extradata_size = old_extradata_size;
+            }
             if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
                 goto fail;
             break;
@@ -426,6 +432,7 @@ static int ffm2_read_header(AVFormatContext *s)
                 ret = AVERROR(EINVAL);
                 goto fail;
             }
+            old_extradata_size = codec->extradata_size;
             buffer = av_malloc(size);
             if (!buffer) {
                 ret = AVERROR(ENOMEM);
@@ -433,6 +440,11 @@ static int ffm2_read_header(AVFormatContext *s)
             }
             avio_get_str(pb, INT_MAX, buffer, size);
             av_set_options_string(codec, buffer, "=", ",");
+            if (codec->extradata_size != old_extradata_size) {
+                av_log(s, AV_LOG_WARNING, "ignoring extradata_size=%d in S2AU chunk\n",
+                       codec->extradata_size);
+                codec->extradata_size = old_extradata_size;
+            }
             ffm_append_recommended_configuration(st, &buffer);
             break;
         }
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to