Skip to content

Commit

Permalink
Don't get or set cells in rows that are less than zero
Browse files Browse the repository at this point in the history
  • Loading branch information
zedr committed Jan 21, 2024
1 parent cb4ef60 commit ad7eba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "../include/queue.h"
#include "../include/gfx.h"

#define TINYCOLS_VERSION "0.8.0"
#define TINYCOLS_VERSION "0.8.1"
#define TICK_TIME 10000
#define MAX_TIMER 180

Expand Down
10 changes: 8 additions & 2 deletions src/tinycols/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

inline enum color get_cell_color(const struct grid *gr, int row, int col)
{
return gr->cells[(row * gr->cols) + col];
if ((row >= 0) && (row <= gr->rows) && (col <= gr->cols)) {
return gr->cells[(row * gr->cols) + col];
} else {
return TRANSPARENT;
}
}

inline void set_cell_color(struct grid *gr, int row, int col, enum color clr)
{
gr->cells[(row * gr->cols) + col] = clr;
if ((row >= 0) && (row <= gr->rows) && (col <= gr->cols)) {
gr->cells[(row * gr->cols) + col] = clr;
}
}

0 comments on commit ad7eba0

Please sign in to comment.