Stop UTF-8 to wchar conversion at end of string
This save us unnecessary conversions and attempts to convert unitialized values, as reported by Valgrind. Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
parent
92caff610b
commit
dc1f0f09c6
3
utf8.c
3
utf8.c
@ -174,6 +174,9 @@ utf8_to_wchar(const char *in, size_t insize, wchar_t *out, size_t outsize,
|
||||
}
|
||||
*out |= high << n_bits;
|
||||
|
||||
if (*out == 0) /* return at end of string */
|
||||
break;
|
||||
|
||||
if (__wchar_forbitten(*out) != 0) {
|
||||
if ((flags & UTF8_IGNORE_ERROR) == 0)
|
||||
return (0); /* forbitten character */
|
||||
|
Loading…
x
Reference in New Issue
Block a user