From 681093616a6a8f19fe8287c81ffafb68e580de43 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Thu, 20 Apr 2023 14:13:45 -0700 Subject: [PATCH] libobs: Check for extension validity in os_generate_formatted_filename In some cases (ffmpeg_mux), the extension and format values are a direct passthrough from arbitrary data. Instead of always postfixing a `.` at the end of a generated path if the extension is invalid, don't postfix the `.` at all. Before: `my_formatted_string.` After: `my_formatted_string` --- libobs/util/platform.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libobs/util/platform.c b/libobs/util/platform.c index 907d5ed69..c80c80275 100644 --- a/libobs/util/platform.c +++ b/libobs/util/platform.c @@ -796,8 +796,11 @@ char *os_generate_formatted_filename(const char *extension, bool space, if (!space) dstr_replace(&sf, " ", "_"); - dstr_cat_ch(&sf, '.'); - dstr_cat(&sf, extension); + if (extension && *extension) { + dstr_cat_ch(&sf, '.'); + dstr_cat(&sf, extension); + } + dstr_free(&c); if (sf.len > 255)