1
0
Fork 0

Fix: truncating strings in settings could leave invalid Utf8 characters

pull/9112/head
rubidium42 2021-04-27 18:25:53 +02:00 committed by rubidium42
parent 0e449f20dc
commit 31c87ba908
1 changed files with 6 additions and 1 deletions

View File

@ -506,7 +506,12 @@ static void Write_ValidateString(void *ptr, const SaveLoad *sld, const char *p)
switch (GetVarMemType(sld->conv)) { switch (GetVarMemType(sld->conv)) {
case SLE_VAR_STRB: case SLE_VAR_STRB:
case SLE_VAR_STRBQ: 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; break;
case SLE_VAR_STR: case SLE_VAR_STR: