From patchwork Sun Dec 17 22:35:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 6841 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp2024097jah; Sun, 17 Dec 2017 14:35:58 -0800 (PST) X-Google-Smtp-Source: ACJfBotgE+SCCNEGA4V3bGrPoD/RPvD6/QpSPzWqTFfK4CTK3DL/RT/2Rwq/Gh6RlgNGrqizUSi7 X-Received: by 10.28.231.19 with SMTP id e19mr10155101wmh.1.1513550157960; Sun, 17 Dec 2017 14:35:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513550157; cv=none; d=google.com; s=arc-20160816; b=utqRH+417bOX9I7nKRcQczC92gmsMIIVEItAeWMdQzMTAgA9SdZYoHvc4W+QvUGwxX 8vBwEYm3D9fs5dQraRAHS5KywxeCcy0NdhJh74iqepw3xgURCbLUWUVMEZw+cBQ7VvY9 xwKHzEJFyXhcNwRy/kW3o897aiWTWu0vq6dwlpo9jljUwWZ1FkAJvs8seDhVRnn42Ho9 NMo1mqgRvKvNMDfXjeUbYnMooLlk1pJ2tJqvl53qIbGyHCAdnvyDj5++upVG8W1UeLIv 4GhfgiMOee9fq7tXp73+cT29aoRullqfjnvdG8VEhfqyKh9+yG0moDCOKg+KQvabhyIu soXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=Zy+GYnifw+MPuD3s9hrWdj3BsRapbdvmYPwXh8i48NE=; b=TKuD2RbLkmPFtBCE9m++Z+vkv/z+gcmH54nhmDVoGAmwBYEKvfbZEpCB6Kp8BgARKL knpWHQfUajItge9Uu2uNqAe5vhwvsHlXoEFKyJvHYLRTDgQ0N7gtudM/xvOqqyphk6A4 Giw7EBzyZWkzWOiYmbSO3wIlM9kososs0gtDgq4rKwcT9pZVJbbcePYhcZhWXYu3UsLS ZBLg0s9Mhuhm/lL5jRX/1VCcE9wI7qE1C3ELSVCDVPvXkhlg+ZSJOU/OL+r+CZZRHNLp bDnGwytdDGEvumuk+nez8IUfe6jipGL1HOVkpTMn1dT2ZbtVdcobEdxeU5cIbY0fsmdK Bnew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u70si6990541wmf.98.2017.12.17.14.35.57; Sun, 17 Dec 2017 14:35:57 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 16C4D689B49; Mon, 18 Dec 2017 00:35:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-2.mx.upcmail.net (vie01a-qmta-pe02-2.mx.upcmail.net [62.179.121.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FAE1680463 for ; Mon, 18 Dec 2017 00:35:34 +0200 (EET) Received: from [172.31.218.33] (helo=vie01a-dmta-pe01-3.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eQhX6-0000Ci-Fb for ffmpeg-devel@ffmpeg.org; Sun, 17 Dec 2017 23:35:44 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eQhX1-00018U-2J for ffmpeg-devel@ffmpeg.org; Sun, 17 Dec 2017 23:35:39 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id nAbV1w01f0S5wYM01AbWqX; Sun, 17 Dec 2017 23:35:31 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 17 Dec 2017 23:35:26 +0100 Message-Id: <20171217223526.20983-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171217223526.20983-1-michael@niedermayer.cc> References: <20171217223526.20983-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Free lengthinc earlier 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Reduces memory needed --- libavcodec/jpeg2000dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index a9633fb9d1..d510004114 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1044,6 +1044,8 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, nb_code_blocks = prec->nb_codeblocks_height * prec->nb_codeblocks_width; for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) { Jpeg2000Cblk *cblk = prec->cblk + cblkno; + if (!cblk->nb_terminationsinc && !cblk->lengthinc) + continue; for (cwsno = 0; cwsno < cblk->nb_lengthinc; cwsno ++) { if (cblk->data_allocated < cblk->length + cblk->lengthinc[cwsno] + 4) { size_t new_size = FFMAX(2*cblk->data_allocated, cblk->length + cblk->lengthinc[cwsno] + 4); @@ -1073,6 +1075,7 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, cblk->data_start[cblk->nb_terminations] = cblk->length; } } + av_freep(&cblk->lengthinc); } } return 0;