[FFmpeg-devel] [PATCH] mxfenc: ensure mxf->body_partition_offset is not NULL before using it

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sat Mar 14 18:03:43 CET 2015


On 14.03.2015 02:17, Mark Reid wrote:
> On Fri, Mar 13, 2015 at 6:02 AM, Andreas Cadhalpun <
> andreas.cadhalpun at googlemail.com> wrote:
> 
>> On 13.03.2015 11:59, Tomas Härdin wrote:
>>> A better solution would
>>> be to figure out why mxf->body_partition_offset becomes NULL so that
>>> index tables and such can be rewritten properly.
>>
>> It can always happen that mxf->body_partition_offset is NULL, e.g. if
>> no memory is left, or if something else fails. Try e.g.:
>> ffmpeg -f lavfi -i testsrc -c:v libx264 -f mxf_opatom
>>
>>
> mxf->body_partition_offset is NULL because currently only AVC Intra 50/100
> h264 is supported.

Yes.

> The encoder figures out the h264 format by parsing the
> h264 packet and doesn't write the body partiton (or even the header
> partition) untill after it parses the first packet. If the packet is
> invalid, nothing get written and mxf->body_partition_offset doesn't get
> allocated.

That's correct.

>  perhaps mxf_write_footer should return a error if
> mxf->body_partition_offset is NULL or just if mxf->header_written == 0
>  before doing trying to write anything.

Well, mxf_write_footer also has to free some allocated memory, which would
get leaked if one just returns...
...like it does in any of the currently present 'return err' cases.

Attached is a patch fixing the memleaks and another returning an error,
if no header was written before the footer.

Best regards,
Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-mxfenc-don-t-try-to-write-footer-without-header.patch
Type: text/x-diff
Size: 991 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150314/c5fb3c30/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mxfenc-fix-memleaks-in-mxf_write_footer.patch
Type: text/x-diff
Size: 2565 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150314/c5fb3c30/attachment-0001.bin>


More information about the ffmpeg-devel mailing list