From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 5A7BB4C30B
	for <ffmpegdev@gitmailbox.com>; Tue,  8 Apr 2025 00:40:39 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E5BF687D79;
	Tue,  8 Apr 2025 03:40:35 +0300 (EEST)
Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net
 [217.70.183.200])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E80B2687CB6
 for <ffmpeg-devel@ffmpeg.org>; Tue,  8 Apr 2025 03:40:28 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 4E0504419D
 for <ffmpeg-devel@ffmpeg.org>; Tue,  8 Apr 2025 00:40:28 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1744072828;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=qBWUgG9asV2ULeC6qrlzpT/VTwlnTiROvK9jIIk8W9A=;
 b=pOTRXz7yHw2vOEZ3BBbtijvcq6yhNGW2NK/KLcXI+zuVdUkZrRDh7GjYUv0mbrKwThtEzR
 Wcz892XZ/N6BvrsHWVYwwxkyMRw5FH9eOM/VkTVc0j7EAvEmxxaTpUBsvWnsC2CrJ2T/V2
 839LIaRZIUvHu9gKg+oTb57Uq5yiCE3hnmwMkFae6vm8nbLCbIbVNECIIDwC6hg9AqreUd
 qKpUgs2hOqTID7rgJJWYcywEu500E51xEIrYsBVYXKUUMQfcMQIblVd5iVi5jzX9wwBMAj
 29Qtf2ivp4m9WFbVHEZe3XBwpl8WCYZJyQN5ZXiAxlJ4c5j+yY5np4njNAhsTQ==
Date: Tue, 8 Apr 2025 02:40:27 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20250408004027.GO4991@pb2>
References: <20250407224523.1455-1-jamrial@gmail.com>
MIME-Version: 1.0
In-Reply-To: <20250407224523.1455-1-jamrial@gmail.com>
X-GND-State: clean
X-GND-Score: -85
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtdduieejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdduhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH] avutil/dict: fix memleak in av_dict_set()
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: multipart/mixed; boundary="===============2903840968919064757=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250408004027.GO4991@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============2903840968919064757==
Content-Type: multipart/signed; micalg=pgp-sha512;
	protocol="application/pgp-signature"; boundary="Z/iJjzFnMqd+tQXP"
Content-Disposition: inline


--Z/iJjzFnMqd+tQXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi James

On Mon, Apr 07, 2025 at 07:45:23PM -0300, James Almer wrote:
> Regression since 19e9a203b7b8e613840b055cdf68303a4fb84581.
>=20
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavutil/dict.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>=20
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index f7dcd07eeb..fafb454fd3 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -99,27 +99,28 @@ int av_dict_set(AVDictionary **pm, const char *key, c=
onst char *value,
>          err =3D AVERROR(EINVAL);
>          goto err_out;
>      }
> +    if (flags & AV_DICT_DONT_STRDUP_KEY)
> +        copy_key =3D (void *)key;
> +    else
> +        copy_key =3D av_strdup(key);
> +    if (!copy_key || (value && !copy_value))
> +        goto enomem;
> +
>      if (!(flags & AV_DICT_MULTIKEY)) {
>          tag =3D av_dict_get(m, key, NULL, flags);
>      } else if (flags & AV_DICT_DEDUP) {
>          while ((tag =3D av_dict_get(m, key, tag, flags))) {
>              if ((!value && !tag->value) ||
>                  (value && tag->value && !strcmp(value, tag->value))) {
> -                if (flags & AV_DICT_DONT_STRDUP_KEY)
> -                    av_free((void*)key);
> -                if (flags & AV_DICT_DONT_STRDUP_VAL)
> -                    av_free((void*)value);
> +                av_free(copy_key);
> +                av_free(copy_value);
>                  return 0;
>              }
>          }
>      }
> -    if (flags & AV_DICT_DONT_STRDUP_KEY)
> -        copy_key =3D (void *)key;
> -    else
> -        copy_key =3D av_strdup(key);

Should be ok
Maybe slightly better if the strdup isnt moved up as theres
a case then where we strdup and free it.

thx

--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.

--Z/iJjzFnMqd+tQXP
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZ/RwTwAKCRBhHseHBAsP
qx61AJ4mCyAO1nRbz5sKNXncFlFle2zTAACdHbDsvxquMS636bKawKEVcNt+4FE=
=g7bG
-----END PGP SIGNATURE-----

--Z/iJjzFnMqd+tQXP--

--===============2903840968919064757==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
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".

--===============2903840968919064757==--