From patchwork Wed Oct 9 07:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 15593 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 8BFA1447223 for ; Wed, 9 Oct 2019 10:36:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 74BBD6881DE; Wed, 9 Oct 2019 10:36:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEA976881D7 for ; Wed, 9 Oct 2019 10:36:07 +0300 (EEST) X-QQ-mid: bizesmtp18t1570606550tbwpf9q5 Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Wed, 09 Oct 2019 15:35:49 +0800 (CST) X-QQ-SSF: 01100000002000K0ZRF1000A0000000 X-QQ-FEAT: X+Lnu8pJYlcIPVj0qrAT/TR060U5Ghalq12wnV1JBi/eV5e7dd3wx+i2KxwHy +aTLMqcwRrelYPKBV+20g4H6GgGy2vph6ufpc67fZi+ksEKKkLcGMz6b356DIxRI+z879Ug jvgBbs41jvu8SHaparbpJShKYNanRNuQSzMkUeAGrpURwmT5JzPI2hJ/Tjpg01lU6G+GbiU JcWwC3xWET1Xriowec/eLyGSeSYARAOp75ygZu60U57OXgoniTCs5OAVJby4GKzS8dOchj/ EuuJSQaJng1bpTM+mY5xLHdE72Rvv9Sb713spiUz05UulS7GcSX6urM1j8BZGB1dXG+nXf/ tG9CkQK X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 15:35:28 +0800 Message-Id: <20191009073530.4505-9-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty In-Reply-To: <20191009073530.4505-1-lq@chinaffmpeg.org> References: <20191009073530.4505-1-lq@chinaffmpeg.org> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v1 09/11] avformat/smacker: fix memleak when avformat_new_stream failed X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Steven Liu --- libavformat/smacker.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index b5c858aa9b..239894dad0 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -172,8 +172,11 @@ static int smacker_read_header(AVFormatContext *s) /* init video codec */ st = avformat_new_stream(s, NULL); - if (!st) + if (!st) { + av_freep(&smk->frm_size); + av_freep(&smk->frm_flags); return AVERROR(ENOMEM); + } smk->videoindex = st->index; st->codecpar->width = smk->width; st->codecpar->height = smk->height; @@ -195,8 +198,11 @@ static int smacker_read_header(AVFormatContext *s) smk->indexes[i] = -1; if (smk->rates[i]) { ast[i] = avformat_new_stream(s, NULL); - if (!ast[i]) + if (!ast[i]) { + av_freep(&smk->frm_size); + av_freep(&smk->frm_flags); return AVERROR(ENOMEM); + } smk->indexes[i] = ast[i]->index; ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; if (smk->aflags[i] & SMK_AUD_BINKAUD) {