From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3436441A4B for ; Sat, 19 Mar 2022 07:50:36 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7661D68AE3E; Sat, 19 Mar 2022 09:50:33 +0200 (EET) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8916C687EBB for ; Sat, 19 Mar 2022 09:50:27 +0200 (EET) Received: by mail-yb1-f174.google.com with SMTP id v35so19509910ybi.10 for ; Sat, 19 Mar 2022 00:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=KVc1nwdgqe9EgsCTjgVwuSrRcYps4WU7pZY+wSV0VsE=; b=bIta4kHZzons+PGznEn/4lEKbMBJGhCytKWe83Htho2H+6KFvcCG5IgXFfhF7YCVhF bcOKkD3zi6AlLHAk0u2RJubBxWSBG8R23kGOm8+/qMjFl1XVXxxA+BrQX6jROdTaNJ0+ Ra/HxGtP8tS35349c4PigP5d+fzgs7sKrU5WcuVKIJARFCeQ2yNCH+dzyokQxguEtwVg /3kMc7p02c0hH4zzCBwstsPaVJFRk8RBP5pLViR5RXhiq2m1lMtUTFI9y96zmpbf0YQK EPoZL8ayDGN0VRg+M/uz0EgHBfqnBeW7rcgEEqQw+4fvXuzkn9TuklyrHBrQQCfUSbvp d2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=KVc1nwdgqe9EgsCTjgVwuSrRcYps4WU7pZY+wSV0VsE=; b=5iEqsATG9TqHnzJPPNguxfCdIHdhQZ/hwapkZgALllz0VfdHuZ7WOypdKboxglfe+m m66d35MqG4829PLlwt+HdHPoLayD7pqiCJUMdHIDvJ1hrGxikQWJ8Y2TxbeuO3zpbAHe v9eFJvP4SadzL7indOyiqo7FWJ9tXVWFz77s1T0Ox/QO4hkcrTw7KxKA2NHJmfTi9sdp yJrF2a/GsRoX/yUs53JebGJPbMj9kPyOaa7N64SlU0sb6Bz9Z088QVzIIK+XYbl+uHSk 7r1WZLbFfJbd3N1vIXjNXNycBZb/eBSmEZaqhtAMaNyedVxF90Crcn8c4s22Mqlbx+mv 3ITA== X-Gm-Message-State: AOAM532u+m0l4NAM2G/VT7WkWndRR9M8tTQ9Mo/IX4F16O9hX0bPTr0K HBa9cbPCyDMCgxVCeZkYc1S0EUHT8VtP+KBDB1N3bz/K X-Google-Smtp-Source: ABdhPJwL8I9Rk9gqHPQPfYuezVC/7PdFEqWDBIVu2pRahvmXXzAc6hqLMs43vz3PB3SOvtWZpNSmxmW260EvYUTVfp8= X-Received: by 2002:a05:6902:20e:b0:627:f1cb:a9ee with SMTP id j14-20020a056902020e00b00627f1cba9eemr12921309ybs.129.1647676225746; Sat, 19 Mar 2022 00:50:25 -0700 (PDT) MIME-Version: 1.0 References: <20220319030407.45503-1-jamrial@gmail.com> In-Reply-To: <20220319030407.45503-1-jamrial@gmail.com> From: Hendrik Leppkes Date: Sat, 19 Mar 2022 08:50:14 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] avcodec/avcodec: don't uninitialize ch_layout 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, Mar 19, 2022 at 4:04 AM James Almer wrote: > > The function is not meant to clear codec parameters, and the lavf demux code > relies on this behavior. > Regression since 327efa66331ebdc0087c6b656059a8df2f404019. > > Signed-off-by: James Almer > --- > libavcodec/avcodec.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c > index 38bdaad4fa..253c9f56cc 100644 > --- a/libavcodec/avcodec.c > +++ b/libavcodec/avcodec.c > @@ -469,6 +469,7 @@ void avsubtitle_free(AVSubtitle *sub) > > av_cold int avcodec_close(AVCodecContext *avctx) > { > + AVChannelLayout ch_layout; > int i; > > if (!avctx) > @@ -524,7 +525,12 @@ 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() will uninitialize avctx->ch_layout, but we want to keep it. > + It will be uninitialized in avcodec_free_context() */ > + ch_layout = avctx->ch_layout; > + memset(&avctx->ch_layout, 0, sizeof(avctx->ch_layout)); > av_opt_free(avctx); > + avctx->ch_layout = ch_layout; > av_freep(&avctx->priv_data); > if (av_codec_is_encoder(avctx->codec)) { > av_freep(&avctx->extradata); This feels pretty ugly and still a bit risky that any call to av_opt_free could invalidate data its not supposed to. Maybe we should have a flag for AVOptions instead where av_opt_free won't touch an entry, because its only there to set/get it, not manage its memory? - Hendrik _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".