Browse Source

Fix native file dialog crash with invalid filter.

Pāvels Nadtočajevs 3 months ago
parent
commit
1484771f26

+ 1 - 1
platform/linuxbsd/freedesktop_portal_desktop.cpp

@@ -670,7 +670,7 @@ Error FreeDesktopPortalDesktop::file_dialog_show(DisplayServer::WindowID p_windo
 		Vector<String> tokens = p_filters[i].split(";");
 		Vector<String> tokens = p_filters[i].split(";");
 		if (tokens.size() >= 1) {
 		if (tokens.size() >= 1) {
 			String flt = tokens[0].strip_edges();
 			String flt = tokens[0].strip_edges();
-			String mime = (tokens.size() >= 2) ? tokens[2].strip_edges() : String();
+			String mime = (tokens.size() >= 3) ? tokens[2].strip_edges() : String();
 			if (!flt.is_empty() || !mime.is_empty()) {
 			if (!flt.is_empty() || !mime.is_empty()) {
 				if (tokens.size() >= 2) {
 				if (tokens.size() >= 2) {
 					if (flt == "*.*") {
 					if (flt == "*.*") {

+ 2 - 2
platform/macos/godot_open_save_delegate.mm

@@ -119,7 +119,7 @@
 				Vector<String> tokens = p_filters[i].split(";");
 				Vector<String> tokens = p_filters[i].split(";");
 				if (tokens.size() >= 1) {
 				if (tokens.size() >= 1) {
 					String flt = tokens[0].strip_edges();
 					String flt = tokens[0].strip_edges();
-					String mime = (tokens.size() >= 2) ? tokens[2].strip_edges() : String();
+					String mime = (tokens.size() >= 3) ? tokens[2].strip_edges() : String();
 					int filter_slice_count = flt.get_slice_count(",");
 					int filter_slice_count = flt.get_slice_count(",");
 
 
 					NSMutableArray *type_filters = [[NSMutableArray alloc] init];
 					NSMutableArray *type_filters = [[NSMutableArray alloc] init];
@@ -173,7 +173,7 @@
 			Vector<String> tokens = p_filters[0].split(";");
 			Vector<String> tokens = p_filters[0].split(";");
 			if (tokens.size() >= 1) {
 			if (tokens.size() >= 1) {
 				String flt = tokens[0].strip_edges();
 				String flt = tokens[0].strip_edges();
-				String mime = (tokens.size() >= 2) ? tokens[2] : String();
+				String mime = (tokens.size() >= 3) ? tokens[2] : String();
 				int filter_slice_count = flt.get_slice_count(",");
 				int filter_slice_count = flt.get_slice_count(",");
 
 
 				NSMutableArray *type_filters = [[NSMutableArray alloc] init];
 				NSMutableArray *type_filters = [[NSMutableArray alloc] init];