mov: Fix handling of zero-length metadata values

Since 3cec81f4d4, a zero-length metadata value would try to
allocate 2*0 bytes, where av_malloc() returns NULL.

Always add one to the allocated length, to allow space for
a null terminator in the zero-length case.

Incidentally, this fixes fate-alac on RVCT 4.0, where a compiler
bug seems to mess up the mov muxer to the point that it writes
the wrong sort of metadata. Previously this bug was undetected,
but since 3cec81f4d4 such mov files started returning
AVERROR(ENOMEM) in the mov demuxer.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2014-12-15 12:09:10 +02:00
parent 10d4c5e55e
commit 6f4364aba9
1 changed files with 1 additions and 1 deletions

View File

@ -383,7 +383,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR_INVALIDDATA;
// allocate twice as much as worst-case
str_size_alloc = raw ? str_size + 1 : str_size * 2;
str_size_alloc = (raw ? str_size : str_size * 2) + 1;
str = av_malloc(str_size_alloc);
if (!str)
return AVERROR(ENOMEM);