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 9316F4874C for ; Wed, 17 Jan 2024 09:22:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6598168CE0F; Wed, 17 Jan 2024 11:22:46 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FD8A68C845 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=I/Uh9cSS; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 83F34EE8 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 Ei8FzbKcBDRD for ; Wed, 17 Jan 2024 10:22:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1705483358; bh=UW5NM9NkCS6gl79BoFmSEV/FToN0bvBRecJ/WQ7j02c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I/Uh9cSSTBNX8QpEBKCPDDgWM5eQ6r72XMrAChGcOUk/PtNnR7SIvCPFjkhEo7fhz u/VDnkcqSBrOpgNUzRYzQfxrmUIK8WmoQpjKiGtxCmqG+EAWVt+WAJPAkTo7VEnk6s Z5RfU+Y0FH/zQpCcJvWIekG/qfn5oHPVzBpGDubVcRIt5CZWTbS+GfrbAp4ZS+G9nH 4pQuxNgpL3HiMT/AzVZVmeYjENt9HVdDyLGxftptZb8taP4dKt6OnxkYqBwnIhrUa5 QtyzzUjyagamHWxD0wnma9ViV7WvnmMfPcKp5bTJnGM9GYQ9yZkIyVSoQu6dqtVsg1 2AKgqoBACNsmQ== 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 18BA614E4 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 F16613A054A for ; Wed, 17 Jan 2024 10:22:37 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 Jan 2024 10:22:29 +0100 Message-ID: <20240117092233.8503-2-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 2/6] fftools/ffplay: make option strings 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 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: Do not store the supplied arg pointer directly. While that is valid for now, it will become ephemeral in the future commits. --- fftools/ffplay.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 3c378bca2c..356d061dee 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -400,7 +400,10 @@ static int opt_add_vfilter(void *optctx, const char *opt, const char *arg) if (ret < 0) return ret; - vfilters_list[nb_vfilters - 1] = arg; + vfilters_list[nb_vfilters - 1] = av_strdup(arg); + if (!vfilters_list[nb_vfilters - 1]) + return AVERROR(ENOMEM); + return 0; } @@ -1305,7 +1308,13 @@ static void do_exit(VideoState *is) if (window) SDL_DestroyWindow(window); uninit_opts(); + for (int i = 0; i < nb_vfilters; i++) + av_freep(&vfilters_list[i]); av_freep(&vfilters_list); + av_freep(&video_codec_name); + av_freep(&audio_codec_name); + av_freep(&subtitle_codec_name); + av_freep(&input_filename); avformat_network_deinit(); if (show_status) printf("\n"); @@ -3594,8 +3603,10 @@ static int opt_input_file(void *optctx, const char *filename) return AVERROR(EINVAL); } if (!strcmp(filename, "-")) - filename = "fd:"; - input_filename = filename; + filename = "pipe:"; + input_filename = av_strdup(filename); + if (!input_filename) + return AVERROR(ENOMEM); return 0; } @@ -3603,6 +3614,7 @@ static int opt_input_file(void *optctx, const char *filename) static int opt_codec(void *optctx, const char *opt, const char *arg) { const char *spec = strchr(opt, ':'); + const char **name; if (!spec) { av_log(NULL, AV_LOG_ERROR, "No media specifier was specified in '%s' in option '%s'\n", @@ -3610,16 +3622,20 @@ static int opt_codec(void *optctx, const char *opt, const char *arg) return AVERROR(EINVAL); } spec++; + switch (spec[0]) { - case 'a' : audio_codec_name = arg; break; - case 's' : subtitle_codec_name = arg; break; - case 'v' : video_codec_name = arg; break; + case 'a' : name = &audio_codec_name; break; + case 's' : name = &subtitle_codec_name; break; + case 'v' : name = &video_codec_name; break; default: av_log(NULL, AV_LOG_ERROR, "Invalid media specifier '%s' in option '%s'\n", spec, opt); return AVERROR(EINVAL); } - return 0; + + av_freep(name); + *name = av_strdup(arg); + return *name ? 0 : AVERROR(ENOMEM); } static int dummy; -- 2.42.0 _______________________________________________ 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".