Prevent overflow beyond the end of string in textfieldrep()
Bug-Debian: https://github.com/tats/w3m/issues/79
This commit is contained in:
2
form.c
2
form.c
@@ -526,6 +526,8 @@ textfieldrep(Str s, int width)
|
|||||||
for (i = 0; i < s->length; i += c_len) {
|
for (i = 0; i < s->length; i += c_len) {
|
||||||
c_type = get_mctype((unsigned char *)&s->ptr[i]);
|
c_type = get_mctype((unsigned char *)&s->ptr[i]);
|
||||||
c_len = get_mclen(&s->ptr[i]);
|
c_len = get_mclen(&s->ptr[i]);
|
||||||
|
if (i + c_len > s->length)
|
||||||
|
break;
|
||||||
if (s->ptr[i] == '\r')
|
if (s->ptr[i] == '\r')
|
||||||
continue;
|
continue;
|
||||||
k = j + get_mcwidth(&s->ptr[i]);
|
k = j + get_mcwidth(&s->ptr[i]);
|
||||||
|
Reference in New Issue
Block a user