From patchwork Mon Sep 14 05:27:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22368 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 C3DA244A762 for ; Mon, 14 Sep 2020 08:36:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE56868BC64; Mon, 14 Sep 2020 08:36:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CDD3868BA38 for ; Mon, 14 Sep 2020 08:36:24 +0300 (EEST) Received: by mail-lf1-f68.google.com with SMTP id x69so12016186lff.3 for ; Sun, 13 Sep 2020 22:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=191hsLZQzMyrLAChgXYD8eP0jITwaEPjHi//EHy1IGw=; b=uLw43A6SSOpL7/YALxVejuR46nN+j1M2MQRpsLRi2lx/A7Hzbjviv6qa8aqv9iD1Un mLkkPre9BULIxqKj6Q5INKmsXdY4MWAA1mV+wA/O9lEREPfnULQe0YYT5b94iKIRq8PI zk5Rtmec5XqeIC6Z1IJFUSX5lAQNQuyntENPpZF6N81TtOaCNG21NlIaerj92bifyeIo CuCbLeUIxa9EyyhAAUWYUJoxtIdo7zK1BZcIHQ/UYOkF2Xq8N4KLoXcVHa3KvGOj1jMp yG6m+++zf7rV3qXUdsk+WV2OE8VQbpHYGJYLHFnvX9gaZzcSge9cVIGDkjsl2JyKeKQN jBBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=191hsLZQzMyrLAChgXYD8eP0jITwaEPjHi//EHy1IGw=; b=XiSx0LGpWbQRanrx1NQ5WV9zr2IGPqKw9bOdWO2fQy+q6sVwD8E+v0GMVSXPIJwYwI qV/JFKXANzgY7SkRjy1I68+5LdSmaZZwBNljVxtjFT1ubzEBeot3LSIWDHK8fcUa1o8T kN0B4vS9mOTBnhVZFh94ZRlO3rRNL1lHv4pF7Alr2j9dn9uKXFXXwWpVYRTECls8a6/g xw0fSmxMX8t99itKDubRcl0wWYYjlcq9dNx7KUlOxY6B7aOZ7KpwKbKd4UXshcn5SXEs 2s6A1S5DEb/N6xlIq1/IKejVk9VPl5EaBvg/LBPrFF22kovnfHeEpoHx9sWjxkVKB5yP h1MQ== X-Gm-Message-State: AOAM533Vqt2wcf0JqVGysLhDYCo40FlP2c/AKghLnNYYB5ENHO71/x8d ibAYiADm6PRlK4K45tXWzJZpbXuOU/w= X-Google-Smtp-Source: ABdhPJyjpB1c3BoBCV/IdwGELvX8Fz/aS+G0AKCLAnEJrtAuLA3KcnYBrKrlvx2LAcxJJrBEE+ADyA== X-Received: by 2002:a17:906:454a:: with SMTP id s10mr12807441ejq.138.1600061296871; Sun, 13 Sep 2020 22:28:16 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f4sm8251421edm.76.2020.09.13.22.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:16 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:25 +0200 Message-Id: <20200914052747.124118-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/40] avcodec/alacenc: Don't free unnecessarily 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The init function of the ALAC encoder calls its own close function if a call to ff_lpc_init() fails; yet nothing has been allocated before that point (except extradata which is freed generically) and ff_lpc_init() can be expected to clean up after itself on error (the documentation does not say anything to the contrary and the current implementation can only fail if the only allocation fails, so there is nothing to clean up on error anyway), so this is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/alacenc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index fc5fa270e6..9d135d1350 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -535,10 +535,8 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) avctx->bits_per_raw_sample); avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) { - ret = AVERROR(ENOMEM); - goto error; - } + if (!avctx->extradata) + return AVERROR(ENOMEM); avctx->extradata_size = ALAC_EXTRADATA_SIZE; alac_extradata = avctx->extradata; @@ -566,8 +564,7 @@ FF_DISABLE_DEPRECATION_WARNINGS avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", avctx->min_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->min_prediction_order = avctx->min_prediction_order; @@ -578,8 +575,7 @@ FF_DISABLE_DEPRECATION_WARNINGS avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->max_prediction_order = avctx->max_prediction_order; @@ -591,8 +587,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", s->min_prediction_order, s->max_prediction_order); - ret = AVERROR(EINVAL); - goto error; + return AVERROR(EINVAL); } s->avctx = avctx; @@ -600,13 +595,10 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order, FF_LPC_TYPE_LEVINSON)) < 0) { - goto error; + return ret; } return 0; -error: - alac_encode_close(avctx); - return ret; } static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,