1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix crash caused by trailing spaces

This commit is contained in:
Julian
2025-03-08 11:56:40 -05:00
parent b5bdb88062
commit 659d1b5d0c
5 changed files with 24 additions and 8 deletions

View File

@@ -1175,7 +1175,7 @@ String String::get_slicec(char32_t p_splitter, int p_slice) const {
}
}
Vector<String> String::split_spaces() const {
Vector<String> String::split_spaces(int p_maxsplit) const {
Vector<String> ret;
int from = 0;
int i = 0;
@@ -1199,6 +1199,11 @@ Vector<String> String::split_spaces() const {
}
if (empty && inside) {
if (p_maxsplit > 0 && p_maxsplit == ret.size()) {
// Put rest of the string and leave cycle.
ret.push_back(substr(from));
break;
}
ret.push_back(substr(from, i - from));
inside = false;
}