Skip to content

Commit

Permalink
ui: add some bound checks
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Mar 15, 2017
1 parent fbf5c1b commit 702a97e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui-terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ static bool ui_style_define(UiWin *w, int id, const char *style) {
}

static void ui_style(UiTerm *tui, int x, int y, int len, UiTermWin *win, enum UiStyle style_id) {
if (x < 0 || x >= tui->width || y < 0 || y >= tui->height)
return;
CellStyle style = tui->styles[(win ? win->id : 0)*UI_STYLE_MAX + style_id];
Cell (*cells)[tui->width] = (void*)tui->cells;
int end = x + len;
Expand All @@ -203,6 +205,8 @@ static void ui_style(UiTerm *tui, int x, int y, int len, UiTermWin *win, enum Ui

static void ui_draw_string(UiTerm *tui, int x, int y, const char *str, UiTermWin *win, enum UiStyle style_id) {
debug("draw-string: [%d][%d]\n", y, x);
if (x < 0 || x >= tui->width || y < 0 || y >= tui->height)
return;
CellStyle style = tui->styles[(win ? win->id : 0)*UI_STYLE_MAX + style_id];
// FIXME: does not handle double width characters etc, share code with view.c?
Cell (*cells)[tui->width] = (void*)tui->cells;
Expand Down

0 comments on commit 702a97e

Please sign in to comment.