On 18.03.2015 16:59, tomas.har...@codemill.se wrote:
> On 2015-03-17 16:13, Andreas Cadhalpun wrote:
>> On 17.03.2015 10:17, tomas.har...@codemill.se wrote:
>>> On 2015-03-14 18:03, Andreas Cadhalpun wrote:
>>> [PATCH 2/2] mxfenc: don't try to write footer without header:
>>>
>>>> +    if (!mxf->header_written ||
>>>> +        (s->oformat == &ff_mxf_opatom_muxer && 
>>>> !mxf->body_partition_offset)) {
>>>> +        err = AVERROR_UNKNOWN;
>>>> +        goto end;
>>>> +    }
>>>> +
>>>
>>> AVERROR_UNKNOWN?
>>
>> It's unclear why the header was not written or body_partition_offset
>> not allocated. It could e.g. be due to invalid options, not supported
>> codecs, or just out of memory.
>> Do you think AVERROR(EINVAL) or even just -1 would be better?
>>
>> Best regards,
>> Andreas
> 
> No preference really. Perhaps a comment though?

OK. New patch with comment attached.

Best regards,
Andreas

>From 1424c87b9a786555b294fb9daa9fd2a67be9a30d Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Wed, 18 Mar 2015 21:57:58 +0100
Subject: [PATCH] mxfenc: don't try to write footer without header

This fixes a crash, when trying to mux h264 into mxf_opatom.

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

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index e9c4a9d..0349e5d 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2402,6 +2402,13 @@ static int mxf_write_footer(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     int err = 0;
 
+    if (!mxf->header_written ||
+        (s->oformat == &ff_mxf_opatom_muxer && !mxf->body_partition_offset)) {
+        /* reason could be invalid options/not supported codec/out of memory */
+        err = AVERROR_UNKNOWN;
+        goto end;
+    }
+
     mxf->duration = mxf->last_indexed_edit_unit + mxf->edit_units_count;
 
     mxf_write_klv_fill(s);
-- 
2.1.4

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

Reply via email to