From patchwork Wed Oct 9 07:35:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 15587 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 E8DAF447006 for ; Wed, 9 Oct 2019 10:35:59 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D5DFC6881A0; Wed, 9 Oct 2019 10:35:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E00336881A0 for ; Wed, 9 Oct 2019 10:35:52 +0300 (EEST) X-QQ-mid: bizesmtp22t1570606539t7x03g1n Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Wed, 09 Oct 2019 15:35:39 +0800 (CST) X-QQ-SSF: 01100000002000K0ZRF1000A0000000 X-QQ-FEAT: FtiPHz2NrtXoxaZzLOYL+9wIz8TVU80XWDnu4H/qrHgeqvBdOr6BflnWDQ7aL 3j1hFAxywDd9aPG+0Za+LPA0XhtFjXCwJs7Ao1GHtlsGK8q64qxXIbyd+sVbr1M6GQRZLCJ 9KlS4fAK7JC2H8IGpNHxpivXylt6T0qjiY/z/5J6qLzS7bjovyJyAFsD1Luv/qsuyVOfxSn FsTZtZVIhC/WH3+Slwtl63aNMOjT3c4WBtT+jBtRwmZ9iIJ39YrnoMp+SE/RUt5WK/zcou7 NVEF9eAzsmAdLxK675aLt7eXpx8IKDsGh6sPYsOJlfFo3dv9QZcOZEEb5gV0dLwy+liRhQY J6jl7Q8 X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 15:35:23 +0800 Message-Id: <20191009073530.4505-4-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:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v1 04/11] avformat/jvdec: fix memleak when read_header 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/jvdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 18c81f0de7..17ada7b0f1 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -113,9 +113,10 @@ static int read_header(AVFormatContext *s) return AVERROR(ENOMEM); jv->frames = av_malloc(ast->nb_index_entries * sizeof(JVFrame)); - if (!jv->frames) + if (!jv->frames) { + av_freep(&ast->index_entries); return AVERROR(ENOMEM); - + } offset = 0x68 + ast->nb_index_entries * 16; for (i = 0; i < ast->nb_index_entries; i++) { AVIndexEntry *e = ast->index_entries + i; @@ -137,6 +138,8 @@ static int read_header(AVFormatContext *s) - jvf->palette_size < 0) { if (s->error_recognition & AV_EF_EXPLODE) { read_close(s); + av_freep(&jv->frames); + av_freep(&ast->index_entries); return AVERROR_INVALIDDATA; } jvf->audio_size =