From patchwork Wed Jan 17 09:22:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45630 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c58a:b0:199:de12:6fa6 with SMTP id gn10csp232030pzb; Wed, 17 Jan 2024 01:23:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1ncEvM6mY0pP8X4dQA5vYZPSlSJcoe1eqjMzaFxCA4WR1v4sobpf2LXtYxSGdqqsxQGY3 X-Received: by 2002:aa7:da92:0:b0:559:e2d7:69f8 with SMTP id q18-20020aa7da92000000b00559e2d769f8mr196602eds.15.1705483396999; Wed, 17 Jan 2024 01:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705483396; cv=none; d=google.com; s=arc-20160816; b=L+re5IV0GG5n7k52TR8y4Pg/tBQM+1HevK4nPi5ruFFkETAOPzNrdT3MSXqSnvSTty CW5cddUkOYHK5g4sE3vcz0p5tHLMpakxfDQLYam/FQZDG0xJdAzLXkcb+zdoPqlAu5Wv /Rlo8qVfrFbwm43WGQrGBWVmYKpO/UrRezVjPBUtvx5faEx38ePpAiQUghMpPwi4sWhY iNs8wSdILnAypabTEPF0jWs/RzokjWolXP7uK6ihOLkMwQ+zXgRgWvYtP5M4vjQw20wi ZHQmoNYYIRzciG1Qfebmhn8joHkJxH6HpX0/DMxeKzIywOSUFar4xVc5pZQs/lI3JoSZ H2Bw== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=5CMCXtxM8AFvQPfmp/05ayI81FGFBGpujxs/BN2bOrU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=dKIugB72Y3VOvtvCBe3cTtOz0HKZDs2LJNkm9wSAYwfWpegVek4LK30C+f6K9RS0RJ PzXabrJ05Hixm6eecdPZLZvneBSw0k3epwjha1qNU+Ui7AFXzsgTlQXqVw9a5AC8KV8i qU6ATNwUyP37RYBCxsWDVwEb11PGicUpXd7KsHqA1ShGxmVpDST7xCzW8DmWjPjgKxY3 hUCAGXntQqK4d3uDRKMXQL3jfMVvO+h/5tnZmjMX99Bko2LNV/TOfkXAHEdsDp6+ut0+ IK8MJGRcVTVETIPjl8rPz1lUxTVEWpdgQtVhqzjZk0i4+EfChiDdDAP98vI9qxaPXZi0 0Keg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bhtZWUH6; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id et9-20020a056402378900b0055763df0070si5681391edb.140.2024.01.17.01.23.16; Wed, 17 Jan 2024 01:23:16 -0800 (PST) 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=@khirnov.net header.s=mail header.b=bhtZWUH6; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C85C468D01C; Wed, 17 Jan 2024 11:22:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3CDC968CD77 for ; Wed, 17 Jan 2024 11:22:40 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=bhtZWUH6; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id D836B14E4 for ; Wed, 17 Jan 2024 10:22:39 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id x6d8vHdoFgmx for ; Wed, 17 Jan 2024 10:22:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1705483358; bh=4KCWgj2D9zhL9ZEzLHGH2MtGnMep2V7HvoRTNhb6mUI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bhtZWUH6novj7qK2hZ20nE2FvS1euGuOBYCpwn0zGNMCeRAIBhz4pTyQEfai0z4hi 0+cLc6D+fE0U8ewdwCcoTIR0Nqsf5YWAc41OmFGYMPGcPYS199ifMl21MO8lP2/iCI 0eGLfbHToZdfj89YNAhQvWVkr/ILeTNa/eAbPPwqWFEWsn4Z6yI/9R1FxZOdh2EsiT aLbsjrRVNX3DFfmIRp+xBtGS3mFnXYcS20ME9lnq5WaHbhQ8x9gBXwsSWv4x87WY0q eek0wHnmcFRdbSnEDdgOOgydWBVbA24TMgSo3h9lzHlNqGQcEpp2vsZXqotpEjJnj5 YTdKeGgvR7tAQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 1EC4F19B7 for ; Wed, 17 Jan 2024 10:22:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 086BE3A0582 for ; Wed, 17 Jan 2024 10:22:38 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Jan 2024 10:22:30 +0100 Message-ID: <20240117092233.8503-3-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240117092233.8503-1-anton@khirnov.net> References: <20240117092233.8503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] fftools/ffmpeg: make attachment filenames dynamically allocated 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: 3K0i2mUA5WDn Do not store the supplied arg pointer directly. While that is valid for now, it will become ephemeral in the future commits. --- fftools/ffmpeg_opt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index ea995f2b5f..563f443bd8 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -124,6 +124,9 @@ static void uninit_options(OptionsContext *o) #if FFMPEG_OPT_MAP_CHANNEL av_freep(&o->audio_channel_maps); #endif + + for (i = 0; i < o->nb_attachments; i++) + av_freep(&o->attachments[i]); av_freep(&o->attachments); av_dict_free(&o->streamid); @@ -494,7 +497,10 @@ static int opt_attach(void *optctx, const char *opt, const char *arg) if (ret < 0) return ret; - o->attachments[o->nb_attachments - 1] = arg; + o->attachments[o->nb_attachments - 1] = av_strdup(arg); + if (!o->attachments[o->nb_attachments - 1]) + return AVERROR(ENOMEM); + return 0; }