From 4f25ca8cd2265b1bbcf0ae71fb6102de01648cb8 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Fri, 27 Aug 2021 18:43:37 +0200 Subject: [PATCH] E-Wireless: Fix bad memory access And a couple of cleanups. --- epplets/E-Wireless.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/epplets/E-Wireless.c b/epplets/E-Wireless.c index d90efe7..2020834 100644 --- a/epplets/E-Wireless.c +++ b/epplets/E-Wireless.c @@ -19,7 +19,7 @@ static int *cpu_hist = NULL; static int hist_pos = 0; static int color = 0; -static unsigned char colors[7][3][3] = { +static const unsigned char colors[7][3][3] = { {{0x00, 0x23, 0x00}, {0x00, 0x50, 0x00}, {0x00, 0xff, 0x00}}, //green {{0x00, 0x00, 0x23}, {0x00, 0x00, 0x50}, {0x00, 0x00, 0xff}}, //blue {{0x23, 0x00, 0x00}, {0x50, 0x00, 0x00}, {0xff, 0x00, 0x00}}, //red @@ -31,7 +31,7 @@ static unsigned char colors[7][3][3] = { static void draw_line(unsigned char *rgb, int x1, int y1, int x2, int y2, - unsigned char *clr) + const unsigned char *clr) { unsigned char *rptr; int i, steep = 0, sx, sy, dx, dy, e; @@ -115,6 +115,8 @@ draw_graph(void) j = ((hist_pos + 1) % WIDTH); y = HEIGHT - ((HEIGHT * cpu_hist[j]) / 100); + if (y >= HEIGHT) + y = HEIGHT - 1; for (i = 0; i < WIDTH - 1; i++) { j++; @@ -272,5 +274,5 @@ main(int argc, char *argv[]) Epplet_show(); Epplet_Loop(); - return (0); + return 0; }