--- ./src/table.c.orig 2011-08-16 16:52:48.000000000 -0500 +++ ./src/table.c 2012-08-08 21:25:15.080344805 -0500 @@ -550,7 +550,7 @@ if (G_UNLIKELY (*array == NULL)) { *array = g_value_array_new(1); } - g_value_set_long(&value, total); + g_value_set_long(&value, CLAMP (total, 0, G_MAXUSHORT)); g_value_array_append(*array, &value); } while (i++ < arginfo->length); g_value_unset(&value); --- ./src/vteseq.c.orig 2011-08-16 16:52:48.000000000 -0500 +++ ./src/vteseq.c 2012-08-08 21:25:15.104344804 -0500 @@ -557,7 +557,7 @@ GValueArray *params, VteTerminalSequenceHandler handler) { - vte_sequence_handler_multiple_limited(terminal, params, handler, G_MAXLONG); + vte_sequence_handler_multiple_limited(terminal, params, handler, G_MAXUSHORT); } static void @@ -1392,7 +1392,7 @@ static void vte_sequence_handler_DC (VteTerminal *terminal, GValueArray *params) { - vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_dc); + vte_sequence_handler_multiple_r(terminal, params, vte_sequence_handler_dc); } /* Delete a line at the current cursor position. */ @@ -1785,7 +1785,7 @@ static void vte_sequence_handler_RI (VteTerminal *terminal, GValueArray *params) { - vte_sequence_handler_multiple(terminal, params, vte_sequence_handler_nd); + vte_sequence_handler_multiple_r(terminal, params, vte_sequence_handler_nd); } /* Save cursor (position). */ @@ -2777,8 +2777,7 @@ { GValue *value; VteScreen *screen; - long param, end, row; - int i; + long param, end, row, i, limit; screen = terminal->pvt->screen; /* The default is one. */ param = 1; @@ -2796,7 +2795,13 @@ } else { end = screen->insert_delta + terminal->row_count - 1; } - /* Insert the new lines at the cursor. */ + + /* Only allow to insert as many lines as there are between this row + * and the end of the scrolling region. See bug #676090. + */ + limit = end - row + 1; + param = MIN (param, limit); + for (i = 0; i < param; i++) { /* Clear a line off the end of the region and add one to the * top of the region. */ @@ -2817,8 +2822,7 @@ { GValue *value; VteScreen *screen; - long param, end, row; - int i; + long param, end, row, i, limit; screen = terminal->pvt->screen; /* The default is one. */ @@ -2837,6 +2841,13 @@ } else { end = screen->insert_delta + terminal->row_count - 1; } + + /* Only allow to delete as many lines as there are between this row + * and the end of the scrolling region. See bug #676090. + */ + limit = end - row + 1; + param = MIN (param, limit); + /* Clear them from below the current cursor. */ for (i = 0; i < param; i++) { /* Insert a line at the end of the region and remove one from