diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-03-21 07:31:17 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-07-01 23:32:25 +0200 |
commit | deb796ae42c6f266ea2bca48f406e7ad04746b3a (patch) | |
tree | 124a7966c057c2068394d73836f7367e528b0973 | |
parent | f411e3aede1f17599d02d1ab8d92a3c6d99e6676 (diff) | |
download | ffmpeg-deb796ae42c6f266ea2bca48f406e7ad04746b3a.tar.gz |
avformat/hnm: Check for extradata allocation failure
and also add padding to it; moreover, don't use memcpy to write one byte
to extradata.
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>
(cherry picked from commit 9e0f3352d1f37a739d98df4347a2b60a396a56fe)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r-- | libavformat/hnm.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/hnm.c b/libavformat/hnm.c index 24d4e808a5..9ad457ac83 100644 --- a/libavformat/hnm.c +++ b/libavformat/hnm.c @@ -70,6 +70,7 @@ static int hnm_read_header(AVFormatContext *s) Hnm4DemuxContext *hnm = s->priv_data; AVIOContext *pb = s->pb; AVStream *vst; + int ret; /* default context members */ hnm->pts = 0; @@ -113,10 +114,10 @@ static int hnm_read_header(AVFormatContext *s) vst->codecpar->codec_tag = 0; vst->codecpar->width = hnm->width; vst->codecpar->height = hnm->height; - vst->codecpar->extradata = av_mallocz(1); + if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0) + return ret; - vst->codecpar->extradata_size = 1; - memcpy(vst->codecpar->extradata, &hnm->version, 1); + vst->codecpar->extradata[0] = hnm->version; vst->start_time = 0; |