Commit 6f4364ab authored by Martin Storsjö's avatar Martin Storsjö

mov: Fix handling of zero-length metadata values

Since 3cec81f4, 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 3cec81f4 such mov files started returning
AVERROR(ENOMEM) in the mov demuxer.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent 10d4c5e5
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment