From patchwork Wed Oct 9 07:35:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 15588 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 C36BE447223 for ; Wed, 9 Oct 2019 10:36:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A81756881B6; Wed, 9 Oct 2019 10:36:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpproxy21.qq.com (smtpbg702.qq.com [203.205.195.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14F7C6881A6 for ; Wed, 9 Oct 2019 10:35:58 +0300 (EEST) X-QQ-mid: bizesmtp25t1570606546tam9dcqx Received: from localhost (unknown [47.90.47.25]) by esmtp10.qq.com (ESMTP) with id ; Wed, 09 Oct 2019 15:35:45 +0800 (CST) X-QQ-SSF: 01100000002000K0ZRF1000A0000000 X-QQ-FEAT: yMjnBFdgjhtuRE6UOoeTX7Ydt6oEtjQgW6oq7QoYUsA/pT9/bdNUpW2eNNaHf pTL6mOGjCCj21BX5WACwYCm02oxptawgbisuj9S9YVc2xcafKF46VZyIS7cE/1FWAR4ADmB DDR2ctBh/w+a9nR5WlyGTJFUTlk+9UtWt6kkvHSXuUa0LH30AUTumnjumEad4Vx0WkimKDf 4oXr5G8YtnJnNTdwbrAqTlC/849MVosawzccW+HJXn4LmL2MeMb4xDAe/sYFu4LBaI0+gj4 mE2+91hCAEhCt8jvT2Q5y2Y7PMnNukljJ/3heQC3x/+G+31pgl+GbPo/15FovnhotO/w== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 15:35:26 +0800 Message-Id: <20191009073530.4505-7-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 07/11] 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);