summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_mpeg2.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-11-09 01:04:20 +0000
committerMark Thompson <sw@jkqxz.net>2017-12-02 15:21:30 +0000
commit7bf3f380466eeff24916fd6218aca13e414c6240 (patch)
tree463a35612ce5b07bc2d3872c859ab29abb3f8d99 /libavcodec/cbs_mpeg2.c
parentf6161fccf8c5720ceac1ed1df8ba60ff8fed69f5 (diff)
downloadffmpeg-7bf3f380466eeff24916fd6218aca13e414c6240.tar.gz
cbs: Add padding to slice data allocations
These may be read by the bitstream reader, so they should include the necessary padding for overreads.
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r--libavcodec/cbs_mpeg2.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c
index 3c09377df3..8a4da96a0a 100644
--- a/libavcodec/cbs_mpeg2.c
+++ b/libavcodec/cbs_mpeg2.c
@@ -181,7 +181,8 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
len = unit->data_size;
slice->data_size = len - pos / 8;
- slice->data = av_malloc(slice->data_size);
+ slice->data = av_malloc(slice->data_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
if (!slice->data) {
av_free(slice);
return AVERROR(ENOMEM);
@@ -189,6 +190,8 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx,
memcpy(slice->data,
unit->data + pos / 8, slice->data_size);
+ memset(slice->data + slice->data_size, 0,
+ AV_INPUT_BUFFER_PADDING_SIZE);
slice->data_bit_start = pos % 8;
unit->content = slice;