diff options
author | rubidium <rubidium@openttd.org> | 2010-12-21 09:29:01 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-21 09:29:01 +0000 |
commit | e1d62dc81b7288e58edd8b1cb800e519a3f7496d (patch) | |
tree | e29753847e448b7ab378862d08e32eff75019d67 /src | |
parent | d446fd6766c83495d1cd97314d4a9baac0837b62 (diff) | |
download | openttd-e1d62dc81b7288e58edd8b1cb800e519a3f7496d.tar.xz |
(svn r21555) -Fix [FS#4321]: strings for the query window weren't properly terminated to N characters anymore
Diffstat (limited to 'src')
-rw-r--r-- | src/misc_gui.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index a1327ba1b..9e472b1cf 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1314,6 +1314,12 @@ struct QueryStringWindow : public QueryStringBaseWindow GetString(this->edit_str_buf, str, &this->edit_str_buf[max_bytes - 1]); str_validate(this->edit_str_buf, &this->edit_str_buf[max_bytes - 1], false, true); + /* Make sure the name isn't too long for the text buffer in the number of + * characters (not bytes). max_chars also counts the '\0' characters. */ + while (Utf8StringLength(this->edit_str_buf) + 1 > max_chars) { + *Utf8PrevChar(this->edit_str_buf + strlen(this->edit_str_buf)) = '\0'; + } + if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->orig = strdup(this->edit_str_buf); this->caption = caption; |