tuklib_mbstr_width: Use stricter return value checking

This should make no difference in practice (at least if mbrtowc()
isn't broken).
This commit is contained in:
Lasse Collin 2024-10-21 18:41:41 +03:00
parent b797c44c42
commit 3c16105936
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
1 changed files with 1 additions and 1 deletions

View File

@ -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;