1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-23 06:29:11 +00:00

Fix #13668, fd2949d: Include the \0 in TextBuf max_chars cropping (#13672)

This commit is contained in:
Loïc Guilloux
2025-03-05 12:05:19 +01:00
committed by GitHub
parent 7723625823
commit 0ade7638df

View File

@@ -427,7 +427,7 @@ void Textbuf::Assign(const std::string_view text)
/* 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. */
auto iter = this->buf.begin();
for (size_t len = 0; len < this->max_chars && iter != this->buf.end(); ++len) Utf8Consume(iter);
for (size_t len = 1; len < this->max_chars && iter != this->buf.end(); ++len) Utf8Consume(iter);
if (iter != this->buf.end()) {
this->buf.erase(iter, this->buf.end());