diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index ba53e342da..ec279ed3c9 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -762,8 +762,8 @@ static int ebml_read_ascii(AVIOContext *pb, int size, char **str) */ static int ebml_read_binary(AVIOContext *pb, int length, EbmlBin *bin) { - av_free(bin->data); - if (!(bin->data = av_malloc(length))) + av_fast_padded_malloc(&bin->data, &bin->size, length); + if (!bin->data) return AVERROR(ENOMEM); bin->size = length;