1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

Small fixes to unrechable code, possibly overflows, using NULL pointers

This commit is contained in:
qarmin
2019-06-03 21:52:50 +02:00
parent 8c923fc617
commit 8245db869f
18 changed files with 48 additions and 70 deletions

View File

@@ -2956,26 +2956,12 @@ String String::replace(const char *p_key, const char *p_with) const {
String String::replace_first(const String &p_key, const String &p_with) const {
String new_string;
int search_from = 0;
int result = 0;
while ((result = find(p_key, search_from)) >= 0) {
new_string += substr(search_from, result - search_from);
new_string += p_with;
search_from = result + p_key.length();
break;
int pos = find(p_key);
if (pos >= 0) {
return substr(0, pos) + p_with + substr(pos + p_key.length(), length());
}
if (search_from == 0) {
return *this;
}
new_string += substr(search_from, length() - search_from);
return new_string;
return *this;
}
String String::replacen(const String &p_key, const String &p_with) const {