Răsfoiți Sursa

vlc-video: Fix crash at removing files from missing-file dialog

The callback missing_file_callback will get an empty string when a user
decided to remove the file on the missing file dialog.
Avoid the empty string to be held in files array and remove it.
Also avoid passing an empty file name from the property to internal
functions.
Norihiro Kamae 3 ani în urmă
părinte
comite
ba77ca6592
1 a modificat fișierele cu 8 adăugiri și 1 ștergeri
  1. 8 1
      plugins/vlc-video/vlc-video-source.c

+ 8 - 1
plugins/vlc-video/vlc-video-source.c

@@ -668,6 +668,10 @@ static void vlcs_update(void *data, obs_data_t *settings)
 	for (size_t i = 0; i < count; i++) {
 		obs_data_t *item = obs_data_array_item(array, i);
 		const char *path = obs_data_get_string(item, "value");
+		if (!path || !*path) {
+			obs_data_release(item);
+			continue;
+		}
 		os_dir_t *dir = os_opendir(path);
 
 		if (dir) {
@@ -1154,7 +1158,10 @@ static void missing_file_callback(void *src, const char *new_path, void *data)
 		const char *path = obs_data_get_string(file, "value");
 
 		if (strcmp(path, orig_path) == 0) {
-			obs_data_set_string(file, "value", new_path);
+			if (new_path && *new_path)
+				obs_data_set_string(file, "value", new_path);
+			else
+				obs_data_array_erase(files, i);
 
 			obs_data_release(file);
 			break;