Module: libav Branch: release/11 Commit: 80bd3e5cde1f31cd0e1c2ed702a67b0661b2ae21
Author: Anton Khirnov <an...@khirnov.net> Committer: Sean McGovern <gsean...@gmail.com> Date: Wed Dec 28 13:15:14 2016 +0100 matroskadec: make sure not to leave EbmlBin in an inconsistent state If a read fails, the current code will free the data but leave the size non-zero. Make sure the size is zeroed in such a case. CC: libav-sta...@libav.org Bug-Id: 1001 Found-By: Kamil Frankowicz Signed-off-by: Sean McGovern <gsean...@gmail.com> (cherry picked from commit 9026ec8aaf5fa19cb4fb266c16f608af0d863b2b) --- libavformat/matroskadec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index f073de7..58b2b09 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -747,16 +747,19 @@ 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); + bin->size = 0; + if (!(bin->data = av_mallocz(length + FF_INPUT_BUFFER_PADDING_SIZE))) return AVERROR(ENOMEM); - bin->size = length; bin->pos = avio_tell(pb); if (avio_read(pb, bin->data, length) != length) { av_freep(&bin->data); return AVERROR(EIO); } + bin->size = length; + return 0; } _______________________________________________ libav-commits mailing list libav-commits@libav.org https://lists.libav.org/mailman/listinfo/libav-commits