@@ -746,11 +746,9 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str) | |||||
static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin) | static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin) | ||||
{ | { | ||||
av_free(bin->data); | av_free(bin->data); | ||||
if (!(bin->data = av_malloc(length + FF_INPUT_BUFFER_PADDING_SIZE))) | |||||
if (!(bin->data = av_mallocz(length + FF_INPUT_BUFFER_PADDING_SIZE))) | |||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memset(bin->data + length, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
bin->size = length; | bin->size = length; | ||||
bin->pos = avio_tell(pb); | bin->pos = avio_tell(pb); | ||||
if (avio_read(pb, bin->data, length) != length) { | if (avio_read(pb, bin->data, length) != length) { | ||||
@@ -86,11 +86,10 @@ static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned si | |||||
{ | { | ||||
if (size >= 1<<24) | if (size >= 1<<24) | ||||
return -1; | return -1; | ||||
avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
avctx->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!avctx->extradata) | if (!avctx->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
avctx->extradata_size = avio_read(pb, avctx->extradata, size); | avctx->extradata_size = avio_read(pb, avctx->extradata, size); | ||||
memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); | |||||
if (avctx->extradata_size != size) | if (avctx->extradata_size != size) | ||||
return AVERROR(EIO); | return AVERROR(EIO); | ||||
return 0; | return 0; | ||||
@@ -2381,14 +2381,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) | |||||
int i = st->parser->parser->split(st->codec, pkt->data, pkt->size); | int i = st->parser->parser->split(st->codec, pkt->data, pkt->size); | ||||
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { | if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { | ||||
st->codec->extradata_size = i; | st->codec->extradata_size = i; | ||||
st->codec->extradata = av_malloc(st->codec->extradata_size + | |||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
st->codec->extradata = av_mallocz(st->codec->extradata_size + | |||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
if (!st->codec->extradata) | if (!st->codec->extradata) | ||||
return AVERROR(ENOMEM); | return AVERROR(ENOMEM); | ||||
memcpy(st->codec->extradata, pkt->data, | memcpy(st->codec->extradata, pkt->data, | ||||
st->codec->extradata_size); | st->codec->extradata_size); | ||||
memset(st->codec->extradata + i, 0, | |||||
FF_INPUT_BUFFER_PADDING_SIZE); | |||||
} | } | ||||
} | } | ||||