From b98510de5c2a04b45ae7471a666c36e124df4d36 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 3 Dec 2016 18:32:04 +0100 Subject: [PATCH] avformat/ffmdec: cleanup on extradata memory allocation failure Signed-off-by: Michael Niedermayer --- libavformat/ffmdec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index c5917a1246..1bd380b6a8 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -379,8 +379,10 @@ FF_ENABLE_DEPRECATION_WARNINGS goto fail; } codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!codecpar->extradata) - return AVERROR(ENOMEM); + if (!codecpar->extradata) { + ret = AVERROR(ENOMEM); + goto fail; + } codecpar->extradata_size = size; avio_read(pb, codecpar->extradata, size); } @@ -690,8 +692,10 @@ FF_ENABLE_DEPRECATION_WARNINGS goto fail; } codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!codecpar->extradata) - return AVERROR(ENOMEM); + if (!codecpar->extradata) { + ret = AVERROR(ENOMEM); + goto fail; + } codecpar->extradata_size = size; avio_read(pb, codecpar->extradata, size); }