GUCAMOLE-149: Merge zero-width character fix for potential infinite loop.

This commit is contained in:
James Muehlner 2017-02-01 10:14:53 -08:00
commit 4da4ce7279
3 changed files with 20 additions and 9 deletions

View File

@ -182,6 +182,10 @@ void guac_terminal_buffer_set_columns(guac_terminal_buffer* buffer, int row,
int i, j;
guac_terminal_char* current;
/* Do nothing if glyph is empty */
if (character->width == 0)
return;
/* Build continuation char (for multicolumn characters) */
guac_terminal_char continuation_char;
continuation_char.value = GUAC_CHAR_CONTINUATION;

View File

@ -438,6 +438,10 @@ void guac_terminal_display_set_columns(guac_terminal_display* display, int row,
int i;
guac_terminal_operation* current;
/* Do nothing if glyph is empty */
if (character->width == 0)
return;
/* Ignore operations outside display bounds */
if (row < 0 || row >= display->height)
return;

View File

@ -657,18 +657,21 @@ char* guac_terminal_prompt(guac_terminal* terminal, const char* title,
int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint) {
int width;
/* Build character with current attributes */
guac_terminal_char guac_char;
guac_char.value = codepoint;
guac_char.attributes = term->current_attributes;
width = wcwidth(codepoint);
/* Calculate width in columns */
int width = wcwidth(codepoint);
if (width < 0)
width = 1;
guac_char.width = width;
/* Do nothing if glyph is empty */
else if (width == 0)
return 0;
/* Build character with current attributes */
guac_terminal_char guac_char = {
.value = codepoint,
.attributes = term->current_attributes,
.width = width
};
guac_terminal_set_columns(term, row, col, col + width - 1, &guac_char);