aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-06-01 04:28:12 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-06-02 00:47:33 +0200
commit6f452ad1acadc50abc7d9b1b9d264e940a451ee7 (patch)
treecfd3113d3b37b2c7e2527c0dbf4f5d5389b0bf76
parent4947e569748b3093b4dee3ede3e9525a179a49e7 (diff)
downloadffmpeg-6f452ad1acadc50abc7d9b1b9d264e940a451ee7.tar.gz
fftools/textformat/avtextformat: Fix races when initializing formatters
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--fftools/textformat/avtextformat.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 0b61d353db..14779e6f0c 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -681,31 +681,22 @@ fail:
return ret;
}
-static const AVTextFormatter *registered_formatters[9 + 1];
-
-static void formatters_register_all(void)
+static const AVTextFormatter *const registered_formatters[] =
{
- static int initialized;
-
- if (initialized)
- return;
- initialized = 1;
-
- registered_formatters[0] = &avtextformatter_default;
- registered_formatters[1] = &avtextformatter_compact;
- registered_formatters[2] = &avtextformatter_csv;
- registered_formatters[3] = &avtextformatter_flat;
- registered_formatters[4] = &avtextformatter_ini;
- registered_formatters[5] = &avtextformatter_json;
- registered_formatters[6] = &avtextformatter_xml;
- registered_formatters[7] = &avtextformatter_mermaid;
- registered_formatters[8] = &avtextformatter_mermaidhtml;
-}
+ &avtextformatter_default,
+ &avtextformatter_compact,
+ &avtextformatter_csv,
+ &avtextformatter_flat,
+ &avtextformatter_ini,
+ &avtextformatter_json,
+ &avtextformatter_xml,
+ &avtextformatter_mermaid,
+ &avtextformatter_mermaidhtml,
+ NULL
+};
const AVTextFormatter *avtext_get_formatter_by_name(const char *name)
{
- formatters_register_all();
-
for (int i = 0; registered_formatters[i]; i++) {
const char *end;
if (av_strstart(name, registered_formatters[i]->name, &end) &&