Prevent overflow beyond the end of string in textfieldrep()

Bug-Debian: https://github.com/tats/w3m/issues/79
This commit is contained in:
Tatsuya Kinoshita
2016-12-13 22:24:54 +09:00
parent a4152aaaea
commit 77d8d8d657

2
form.c
View File

@@ -526,6 +526,8 @@ textfieldrep(Str s, int width)
for (i = 0; i < s->length; i += c_len) {
c_type = get_mctype((unsigned char *)&s->ptr[i]);
c_len = get_mclen(&s->ptr[i]);
if (i + c_len > s->length)
break;
if (s->ptr[i] == '\r')
continue;
k = j + get_mcwidth(&s->ptr[i]);