From f8e535a098ef20d90c94be0c4fddef67c9ae09f2 Mon Sep 17 00:00:00 2001 From: glx22 Date: Fri, 28 Feb 2025 02:07:16 +0100 Subject: [PATCH] Fix #13668, fd2949d: Include the `\0` in TextBuf max_chars cropping --- src/textbuf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textbuf.cpp b/src/textbuf.cpp index 6d8401ddd3..3fe748e8d0 100644 --- a/src/textbuf.cpp +++ b/src/textbuf.cpp @@ -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());