Check write location on rect operations (copy, etc.)

This commit is contained in:
Michael Jumper 2013-04-08 00:14:25 -07:00
parent 342824914a
commit 7897be9316

View File

@ -417,6 +417,14 @@ int guac_terminal_copy(guac_terminal* term,
int scrolled_rows = rows; int scrolled_rows = rows;
/* FIXME: If source (but not dest) is partially scrolled out of view, then
* the delta will not be updated properly. We need to pull the data
* from the buffer in such a case.
*/
if (scrolled_src_row < term->delta->height &&
scrolled_dst_row < term->delta->height) {
/* Adjust delta rect height if scrolled out of view */ /* Adjust delta rect height if scrolled out of view */
if (scrolled_src_row + scrolled_rows > term->delta->height) if (scrolled_src_row + scrolled_rows > term->delta->height)
scrolled_rows = term->delta->height - scrolled_src_row; scrolled_rows = term->delta->height - scrolled_src_row;
@ -424,17 +432,14 @@ int guac_terminal_copy(guac_terminal* term,
if (scrolled_dst_row + scrolled_rows > term->delta->height) if (scrolled_dst_row + scrolled_rows > term->delta->height)
scrolled_rows = term->delta->height - scrolled_dst_row; scrolled_rows = term->delta->height - scrolled_dst_row;
/* FIXME: If source (but not dest) is partially scrolled out of view, then
* the delta will not be updated properly. We need to pull the data
* from the buffer in such a case.
*/
/* Update delta */ /* Update delta */
guac_terminal_delta_copy(term->delta, guac_terminal_delta_copy(term->delta,
scrolled_dst_row, dst_col, scrolled_dst_row, dst_col,
scrolled_src_row, src_col, scrolled_src_row, src_col,
cols, rows); cols, rows);
}
/* Update buffer */ /* Update buffer */
guac_terminal_buffer_copy(term->buffer, guac_terminal_buffer_copy(term->buffer,
dst_row, dst_col, dst_row, dst_col,
@ -452,19 +457,23 @@ int guac_terminal_clear(guac_terminal* term,
int scrolled_row = row + term->scroll_offset; int scrolled_row = row + term->scroll_offset;
int scrolled_rows = rows; int scrolled_rows = rows;
/* Adjust delta rect height if scrolled out of view */
if (scrolled_row + scrolled_rows > term->delta->height)
scrolled_rows = term->delta->height - scrolled_row;
/* Build space */ /* Build space */
guac_terminal_char character; guac_terminal_char character;
character.value = ' '; character.value = ' ';
character.attributes = term->current_attributes; character.attributes = term->current_attributes;
if (scrolled_row < term->delta->height) {
/* Adjust delta rect height if scrolled out of view */
if (scrolled_row + scrolled_rows > term->delta->height)
scrolled_rows = term->delta->height - scrolled_row;
/* Fill with color */ /* Fill with color */
guac_terminal_delta_set_rect(term->delta, guac_terminal_delta_set_rect(term->delta,
scrolled_row, col, cols, scrolled_rows, &character); scrolled_row, col, cols, scrolled_rows, &character);
}
guac_terminal_buffer_set_rect(term->buffer, guac_terminal_buffer_set_rect(term->buffer,
row, col, cols, rows, &character); row, col, cols, rows, &character);