From patchwork Mon Sep 14 05:27:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22351 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 EFD0644A49B for ; Mon, 14 Sep 2020 08:28:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC8DC68BB86; Mon, 14 Sep 2020 08:28:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4467168BB3C for ; Mon, 14 Sep 2020 08:28:34 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id nw23so21342953ejb.4 for ; Sun, 13 Sep 2020 22:28:34 -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=aIllyBENsrhJshvS8U58hxXArL4ic58OHkSmTC8dgO4=; b=SyaW32/xxX+HsHT8LEkBa0Ql4vP0BkN1S74fKraKaLMe0S6qB9mjtlmtkrNdnl2YOG /4uoeqwD64Xb0pNEsnt2tNx8UstT27fmxsduBcY+0Qm/IEuVuxIEQT/cyKRlO7vLAuRZ eOgEG4R0xZZxyk8ZHeShi8dGZ0mhjNcZ2kCxsn76dopsI91QyZy1GUqz2KjSKOu07Slg nGckV++KWx4oQvCJCE5964cZaff+ZcSSOMIbqDq1rUurYiTPIb/QX/8lzkn9muZss4g9 9lgACQr3+2af+HLKoVEWy78/mXbTjpOEFRVZ6AhdB3YQob3b4Gk+shVJZmz+gC7rM7B5 D+2Q== 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=aIllyBENsrhJshvS8U58hxXArL4ic58OHkSmTC8dgO4=; b=MU5v4DbJApv+k9Sqps2bWUCrBdf6TE6zcFqKgCRopsuB9WlgFGt1j4r3Lrf//sVFIQ 874+Ho8oLK02oasnSh3lfEW+bT/IZq1FkW4yBr9nHR780xRSKj7VKhWkXl0TJtKx3+my oabE4snjcLrVa73CcT/hhlob2GPsc8ruSHWTmclPwkDYS/hZIOc6mOUj1kLsx/6wuc4D ImD3+PGCArUrY3DXCJrQehro02MZ89ZFyJNAi8aaYaH2Wegq4vSl4VOkyGyh8zG+MQn/ C+5geDcMrPX1akADESDFaE+wsv3jOZQsJAaGvwSuILC7oT8/i2XLrRTN2eFFF2119v+e qDVA== X-Gm-Message-State: AOAM530ivB9IVKchk9eRa4rqeb0GrO2QtxKM/K9lM50V4yya3Wy8SXVs GtTLEq19CSrPLJVTm2yka9FFWZ88pjg= X-Google-Smtp-Source: ABdhPJyUqBEkvUZQ/MwNWkvG1Ss8ij1b7qF3V1j1JAyryjqDBPT3nnPj4dpDypTeLG8hmqnbCuejmg== X-Received: by 2002:a17:906:4c89:: with SMTP id q9mr13526447eju.290.1600061313488; Sun, 13 Sep 2020 22:28:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2020 22:28:32 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Sep 2020 07:27:42 +0200 Message-Id: <20200914052747.124118-19-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 35/40] avcodec/ac3enc_float, eac3enc: Fix leaks on init error 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 AC-3 encoders (both floating- as well as fixed-point) as well as the EAC-3 encoder share code: All use ff_ac3_encode_init() as well as ff_ac3_encode_close(). Until ee726e777b851cdd4e28cdab36b38f0c39e35ea9 ff_ac3_encode_init() called ff_ac3_encode_close() to clean up on error. Said commit removed this and instead set the FF_CODEC_CAP_INIT_CLEANUP flag; but it did the latter only for the fixed-point AC-3 encoder and not for the other two users of ff_ac3_encode_init(). This caused any already allocated buffer to leak upon a subsequent error for the two other encoders. This commit fixes this by adding the FF_CODEC_CAP_INIT_CLEANUP flag to the other two encoders using ff_ac3_encode_init(). Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc_float.c | 1 + libavcodec/eac3enc.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 1f3111af0e..99863a9722 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -153,4 +153,5 @@ AVCodec ff_ac3_encoder = { .supported_samplerates = ff_ac3_sample_rate_tab, .channel_layouts = ff_ac3_channel_layouts, .defaults = ac3_defaults, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 6a90571e56..8e1032f268 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -266,4 +266,5 @@ AVCodec ff_eac3_encoder = { .supported_samplerates = ff_ac3_sample_rate_tab, .channel_layouts = ff_ac3_channel_layouts, .defaults = ac3_defaults, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };