Changeset - r18117:e131567ef758
[Not reviewed]
master
0 1 0
yexo - 13 years ago 2011-09-23 12:26:25
yexo@openttd.org
(svn r22952) -Fix: properly limit the length of strings in a choice list
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_text.cpp
Show inline comments
 
@@ -371,7 +371,9 @@ struct UnmappedChoiceList : ZeroedMemory
 
			for (int i = 0; i < count; i++) {
 
				int idx = (this->type == SCC_GENDER_LIST ? lm->GetReverseMapping(i, true) : i + 1);
 
				const char *str = this->strings[this->strings.Contains(idx) ? idx : 0];
 
				size_t len = strlen(str);
 
				/* Limit the length of the string we copy to 0xFE. The length is written above
 
				 * as a byte and we need room for the final '\0'. */
 
				size_t len = min(0xFE, strlen(str));
 
				memcpy(d, str, len);
 
				d += len;
 
				*d++ = '\0';
0 comments (0 inline, 0 general)