Fix a couple of out of bounds memory reads

This commit is contained in:
Kovid Goyal 2016-12-18 13:58:01 +05:30
parent 73fa3c4a63
commit 3e1dac97ad
2 changed files with 4 additions and 3 deletions

View File

@ -318,7 +318,7 @@ void linebuf_delete_lines(LineBuf *self, index_type num, index_type y, index_typ
for (i = y; i < y + num; i++) {
self->scratch[i] = self->line_map[i];
}
for (i = y; i < ylimit; i++) {
for (i = y; i < ylimit && i + num < self->ynum; i++) {
self->line_map[i] = self->line_map[i + num];
self->continued_map[i] = self->continued_map[i + num];
}

View File

@ -110,8 +110,9 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
Py_CLEAR(self->main_linebuf); self->main_linebuf = n;
bool index_after_resize = false;
if (is_main) {
linebuf_init_line(self->main_linebuf, self->cursor->y);
if (is_x_shrink && (self->main_linebuf->continued_map[self->cursor->y] || line_length(self->main_linebuf->line) > columns)) {
index_type cy = MIN(self->cursor->y, lines - 1);
linebuf_init_line(self->main_linebuf, cy);
if (is_x_shrink && (self->main_linebuf->continued_map[cy] || line_length(self->main_linebuf->line) > columns)) {
// If the client is in line drawing mode, it will redraw the cursor
// line, this can cause rendering artifacts, so ensure that the
// cursor is on a new line