mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
Fix: truncating strings in settings could leave invalid Utf8 characters
This commit is contained in:
parent
0e449f20dc
commit
31c87ba908
@ -506,7 +506,12 @@ static void Write_ValidateString(void *ptr, const SaveLoad *sld, const char *p)
|
||||
switch (GetVarMemType(sld->conv)) {
|
||||
case SLE_VAR_STRB:
|
||||
case SLE_VAR_STRBQ:
|
||||
if (p != nullptr) strecpy((char*)ptr, (const char*)p, (char*)ptr + sld->length - 1);
|
||||
if (p != nullptr) {
|
||||
char *begin = (char*)ptr;
|
||||
char *end = begin + sld->length - 1;
|
||||
strecpy(begin, p, end);
|
||||
str_validate(begin, end, SVS_NONE);
|
||||
}
|
||||
break;
|
||||
|
||||
case SLE_VAR_STR:
|
||||
|
Loading…
Reference in New Issue
Block a user