Skip to content

Commit 34bf9ca

Browse files
committed
added range check to PX macro in freedomgfx module
1 parent 32f2030 commit 34bf9ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

esp32/modfreedomgfx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959
#define imgSize (BADGE_EINK_WIDTH*BADGE_EINK_HEIGHT)
6060
static uint8_t* img = 0;
6161

62-
#define PX(x,y,v) img[((x)+(y)*BADGE_EINK_WIDTH)] = (v)
62+
#define PX(x,y,v) \
63+
if( x>=0 && y>=0 && x < BADGE_EINK_WIDTH && y < BADGE_EINK_HEIGHT) \
64+
img[((x)+(y)*BADGE_EINK_WIDTH)] = (v)
65+
6366
#define ABS(x) (((x)<0)?-(x):(x))
6467

6568
static void gfx_input_poll(uint32_t btn);

0 commit comments

Comments
 (0)