Changeset - r25285:ebbf39bd4458
[Not reviewed]
master
0 1 0
rubidium42 - 3 years ago 2021-04-27 16:25:53
rubidium@openttd.org
Fix: truncating strings in settings could leave invalid Utf8 characters
1 file changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/settings.cpp
Show inline comments
 
@@ -506,7 +506,12 @@ static void Write_ValidateString(void *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:
0 comments (0 inline, 0 general)