From patchwork Thu Oct 10 02:07:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 15651 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 85A18440264 for ; Thu, 10 Oct 2019 05:08:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 669AC6881BF; Thu, 10 Oct 2019 05:08:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A58876881CE for ; Thu, 10 Oct 2019 05:08:11 +0300 (EEST) X-QQ-mid: bizesmtp18t1570673286tr1s0p2w Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Thu, 10 Oct 2019 10:08:06 +0800 (CST) X-QQ-SSF: 01100000002000K0ZRF1B00A0000000 X-QQ-FEAT: oWSi6Zun5Dk8Ahh50uSzFrkBK7N9FkDB5oVoFiJmCxvHOkLwJf1EgJCVZuvfM xcU6j/ePUx4cNu8pS1TORxaqMMMCps0DAQWGhubPwAp0HzNpoiGufiPm7+AugkNGEOPjhnP d05WA37hroV4651Z5tejxrDZacbrxqz1/ad3GilSz5XjxOZtt4tjd/tm6UtN0dEJgNCUxTN tAwcYbyMkjtHqgnnxcXFNNDRMV90IcAOeYea1fcUUNmsfgKsyY6ICE+GnbiE0yR4Xaap1Kc 0CTRrY7d69Pv0rolCOKqQxhUuA7DWinwhRrwuhTkOhyu5wePmczk0o7aI= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Oct 2019 10:07:52 +0800 Message-Id: <20191010020756.30820-4-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty In-Reply-To: <20191010020756.30820-1-lq@chinaffmpeg.org> References: <20191010020756.30820-1-lq@chinaffmpeg.org> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2 4/8] avformat/rl2: fix memleak when read end of file 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/rl2.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libavformat/rl2.c b/libavformat/rl2.c index d847d9aaa8..07696965c7 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -171,18 +171,24 @@ static av_cold int rl2_read_header(AVFormatContext *s) /** read offset and size tables */ for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } chunk_size[i] = avio_rl32(pb); } for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } chunk_offset[i] = avio_rl32(pb); } for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } audio_size[i] = avio_rl32(pb) & 0xFFFF; } @@ -203,7 +209,7 @@ static av_cold int rl2_read_header(AVFormatContext *s) ++video_frame_counter; } - +end: av_free(chunk_size); av_free(audio_size); av_free(chunk_offset);