From 377046e31567554261b5e392a0d4fedc19ce8258 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 14 Dec 2016 13:53:30 +0000 Subject: [PATCH] Handle correctly cases where codepoint_width returns -1 Fixes #972 --- src/string.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string.hh b/src/string.hh index d7e39ff9..6fd2f5fb 100644 --- a/src/string.hh +++ b/src/string.hh @@ -114,7 +114,7 @@ public: explicit String(Codepoint cp, ColumnCount count) { kak_assert(count % codepoint_width(cp) == 0); - int cp_count = (int)(count / codepoint_width(cp)); + int cp_count = (int)(count / std::max(codepoint_width(cp), 1_col)); reserve(utf8::codepoint_size(cp) * cp_count); while (cp_count-- > 0) utf8::dump(std::back_inserter(*this), cp);