diff --git a/src/common/tuklib_mbstr_width.c b/src/common/tuklib_mbstr_width.c index 3c63dd1a..e7052235 100644 --- a/src/common/tuklib_mbstr_width.c +++ b/src/common/tuklib_mbstr_width.c @@ -41,7 +41,7 @@ tuklib_mbstr_width(const char *str, size_t *bytes) while (i < len) { wchar_t wc; const size_t ret = mbrtowc(&wc, str + i, len - i, &state); - if (ret < 1 || ret > len) + if (ret < 1 || ret > len - i) return (size_t)-1; i += ret;