Quellcode durchsuchen

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`
tt2468 vor 2 Jahren
Ursprung
Commit
681093616a
1 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
  1. 5 2
      libobs/util/platform.c

+ 5 - 2
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)