utf8: when looking at the next unichar, honour the size parameter, in utf8_is_printable_newline()

This commit is contained in:
Lennart Poettering 2014-11-07 16:34:00 +01:00
parent f9aa541380
commit 144b3d9e09

View file

@ -150,10 +150,12 @@ bool utf8_is_printable_newline(const char* str, size_t length, bool newline) {
int encoded_len, val;
encoded_len = utf8_encoded_valid_unichar((const char *) p);
val = utf8_encoded_to_unichar((const char*) p);
if (encoded_len < 0 ||
val < 0 ||
(size_t) encoded_len > length)
return false;
val = utf8_encoded_to_unichar((const char*) p);
if (val < 0 ||
is_unicode_control(val) ||
(!newline && val == '\n'))
return false;