From 0ade7638dfecdedcaeda25cd1e22eeb07a9e5c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Wed, 5 Mar 2025 12:05:19 +0100 Subject: [PATCH] Fix #13668, fd2949d: Include the `\0` in TextBuf max_chars cropping (#13672) --- 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());