1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 00:42:45 +01:00

Codechange: Remove broken and unused StrMakeValidInPlace overload. (#13960)

If an otherwise valid string without NUL termination was passed, a NUL was appended out of bounds.
This commit is contained in:
frosch
2025-04-04 11:48:32 +02:00
committed by GitHub
parent 1befa1ccb0
commit 44984f8410
3 changed files with 5 additions and 25 deletions

View File

@@ -188,30 +188,17 @@ static void StrMakeValid(T &dst, const char *str, const char *last, StringValida
}
/**
* Scans the string for invalid characters and replaces then with a
* Scans the string for invalid characters and replaces them with a
* question mark '?' (if not ignored).
* @param str The string to validate.
* @param last The last valid character of str.
* @param settings The settings for the string validation.
*/
void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings settings)
{
char *dst = str;
StrMakeValid(dst, str, last, settings);
*dst = '\0';
}
/**
* Scans the string for invalid characters and replaces then with a
* question mark '?' (if not ignored).
* Only use this function when you are sure the string ends with a '\0';
* otherwise use StrMakeValidInPlace(str, last, settings) variant.
* @param str The string (of which you are sure ends with '\0') to validate.
* @note The string must be properly NUL terminated.
*/
void StrMakeValidInPlace(char *str, StringValidationSettings settings)
{
/* We know it is '\0' terminated. */
StrMakeValidInPlace(str, str + strlen(str), settings);
char *dst = str;
StrMakeValid(dst, str, str + strlen(str), settings);
*dst = '\0';
}
/**