diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-12-12 16:53:17 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-12-27 12:38:08 +0100 |
commit | 9bde6c6be0ea568f6ce646690616a0d4274095d4 (patch) | |
tree | 362e374b93ee0072be3469e478afc23a5a4524a6 /libavformat/microdvddec.c | |
parent | b0d0d7e4d0581ccfeea37cc3fd0d3ca9d999fbfc (diff) | |
download | ffmpeg-9bde6c6be0ea568f6ce646690616a0d4274095d4.tar.gz |
avformat/microdvd: Use \n instead of \0 to end file header
Up until now, the microdvd demuxer uses av_strdup() to allocate the
extradata from a string; its length is set to strlen() + 1, i.e.
including the \0 at the end. Upon remuxing, the muxer would simply copy
the extradata at the beginning, including the \0.
This commit changes this by not adding the \0 to the size of the
extradata; the muxer now delimits extradata by inserting a \n. This
required to change the subtitles-microdvd-remux FATE-test.
Furthermore, the extradata is now allocated with zeroed padding.
The microdvd decoder is not affected by this, as it didn't use the size
of the extradata at all, but treated it as a C-string.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/microdvddec.c')
-rw-r--r-- | libavformat/microdvddec.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c index ca9086afe9..08e6fca09c 100644 --- a/libavformat/microdvddec.c +++ b/libavformat/microdvddec.c @@ -117,10 +117,11 @@ static int microdvd_read_header(AVFormatContext *s) continue; } if (!st->codecpar->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) { - st->codecpar->extradata = av_strdup(line + 11); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); - st->codecpar->extradata_size = strlen(st->codecpar->extradata) + 1; + int ret, size = strlen(line + 11); + ret = ff_alloc_extradata(st->codecpar, size); + if (ret < 0) + return ret; + memcpy(st->codecpar->extradata, line + 11, size); continue; } } |