From patchwork Sun Mar 20 23:18:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 34870 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:ed11:0:0:0:0 with SMTP id hi17csp1213793nkc; Sun, 20 Mar 2022 16:18:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5RbkrA36UIHeAmmsVMzrz0WFbuUrniJEigjq+3DPIZzfw6y2O6/ebCwag4CLd7xbmOsbq X-Received: by 2002:a05:6402:2755:b0:418:ec91:b9b5 with SMTP id z21-20020a056402275500b00418ec91b9b5mr20202306edd.272.1647818324168; Sun, 20 Mar 2022 16:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647818324; cv=none; d=google.com; s=arc-20160816; b=PXS3nGBMEqxf0/5b89mlFxxXyHNh7ZML7xNiO2kyulnxmzj8BaCaPOXj3sSibWokT1 ztVS7S/ZoodkE5x6Zf4Z5rhR+gniFudL407W0k9DqXND6nHRgDc+S8W4zIGgpbQjWU4W KWkNzpW6tUGSlmx3U1cCqVd4lihPXRdxllWS9/2oQw2IINvsmcA2ieV2S9mwmUYZNxb/ vu0Et25IDWgqquWqz+PvJqWG4p/GD2grKkw6pOB2Y/zbbT7OenfLSBttD5gl5RUGSyY0 Jyg6ankFv4mceLdZ7no1uS9K0Uwa/lyR6dkr85a9oviEplWg04wKPWgEyQbLb5Mihos0 YetQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=e4xM0xzpDpH7S1C2TtjW1X+IXDYJo50U8kKoLzEij/s=; b=EifnAZzYEg9GT00fw0lmorcCkc5ocn/JT3GyoXWTtVEaqKnQd5BMdghQV/R8uF+L1r 2SfxcRQhEIl1CU4hOLwsNBTm9SHcI3oX9U2JxJhErJ8QPnqx4Ys4ziZj+NGJKwYMrsL2 1cJMHTU/rXoZr6dY3hOnQeovDtJeM0VIyGkkMfWV2X3NSG2mE+TCx9H7LN3R4kqsvgCA gn6lNV3kpsdHP8S7ywzBp7c1hkrzUH++HtkOtksnmQUzFFBe7PWDb0QPCryXxByqJCra 9krsDYRc+uDzFuI2z5XjOEAGA0XdjJUpkUodSktjn09lmCX8H8uspP9srQLT/7VpFGIY zcZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AL8dCXN0; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y14-20020a1709064b0e00b006df76385f1bsi5533151eju.955.2022.03.20.16.18.43; Sun, 20 Mar 2022 16:18:44 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AL8dCXN0; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E4A8468B11B; Mon, 21 Mar 2022 01:18:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93942689B39 for ; Mon, 21 Mar 2022 01:18:34 +0200 (EET) Received: by mail-oo1-f47.google.com with SMTP id q1-20020a4a7d41000000b003211b63eb7bso17229535ooe.6 for ; Sun, 20 Mar 2022 16:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=W7iUYaUKSyp2OaSf4zIpy+rtTO2P0fwfr5ttfez48zY=; b=AL8dCXN0oddw1MHzCPbbRzjUlcbeT/P7fLhHj9LQFUf0oJaKFlrSi5Oowlziezan1a aW3uDroX0D251RDAd9/j2vsizgHGC+xybkptrEzs4ktL5NUnoalMVv/cOl0yQvRhxfaO rMJygl2OmbQpNwqUcCGfH/Fcg5cs36AbpKBTFLHdo9srQljYQCIM1LlVh6t8xsZriRVW +ZcOh/gKyRBTqTvdRq38WD8jM1VXBYrlVUsXF7alz5mhnOAk2NgdCiSyXQXxe7QuUAw/ 0FC2k0klGsDxmHV/m9fBI80hS7R53hOBAzCe76/XaRtwq1PxFV9wMKXwqj4Dx6w82l0/ BWyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=W7iUYaUKSyp2OaSf4zIpy+rtTO2P0fwfr5ttfez48zY=; b=XxuWRe+bm5r3/xujYEAkl2fQDrEyZa0ocCoGqCLVJB8jNQcsn2EeJG1X7gTIJM/snw WeE70c2fpcMKwyFugnaOR9p2cRbFOzDv/adG1yakVyljlsYKcPytMAuq4WXn1BNhXeg8 JfSzZL9YOK3ZwXH3t5BlV4Vu5Ort89lcUEdnZ0TpRdT8JacJu2iqSG9FIiWuigUwP3Ku KjNgztGTKdaCyOi4Wcywl2kgCwEIi9cWBVkDYHkc2+eoDohVyLNjJisJ4zuvmzeQMPv1 ZNO9+36kpeC1begVAZ+uVeTcIyyl3P9Bj/31BP+XYWF1IHIuLIMh6zn007R8G2Q6gZC7 OOUQ== X-Gm-Message-State: AOAM533bYi5yFpwdyIqRt/d6xskaf1ugQGL25u/eyWtvmB8Vv7xQzsrY dr1UdLiZFkTh+dOUzEWLEk8uRg7WE3gc8g== X-Received: by 2002:a4a:e216:0:b0:320:5471:3284 with SMTP id b22-20020a4ae216000000b0032054713284mr5887171oot.70.1647818312095; Sun, 20 Mar 2022 16:18:32 -0700 (PDT) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id q6-20020a056870028600b000d9be0ee766sm5570151oaf.57.2022.03.20.16.18.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 16:18:31 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 20 Mar 2022 20:18:09 -0300 Message-Id: <20220320231809.40398-1-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/avcodec: don't free AVOption settable fields in avcodec_close() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tYEhXTyofjxI It can uninitialize fields that may still be used after the context was closed, so do it instead in avcodec_free_context(). Signed-off-by: James Almer --- libavcodec/avcodec.c | 1 - libavcodec/options.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 38bdaad4fa..122d09b63a 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -524,7 +524,6 @@ av_cold int avcodec_close(AVCodecContext *avctx) if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) av_opt_free(avctx->priv_data); - av_opt_free(avctx); av_freep(&avctx->priv_data); if (av_codec_is_encoder(avctx->codec)) { av_freep(&avctx->extradata); diff --git a/libavcodec/options.c b/libavcodec/options.c index 33f11480a7..91335415c1 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -172,7 +172,7 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->intra_matrix); av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); - av_channel_layout_uninit(&avctx->ch_layout); + av_opt_free(avctx); av_freep(pavctx); }