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`
This commit is contained in:
tt2468 2023-04-20 14:13:45 -07:00 committed by Jim
parent f75fa626d8
commit 681093616a

View file

@ -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)