From 0fd04941a3b09f2660817ec2903b8520c9d3f33f Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Sun, 3 Jun 2012 23:37:33 +0200 Subject: matrix plugin: Fix out-of-bounds array access. Unify for-loop style. Change-Id: I74ec8e559b80bee6c7de02193e943244dcf352c4 --- apps/plugins/matrix.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/plugins/matrix.c b/apps/plugins/matrix.c index 428dc093bf..087a501474 100644 --- a/apps/plugins/matrix.c +++ b/apps/plugins/matrix.c @@ -88,14 +88,14 @@ static void matrix_init(void) { rb->srand(*rb->current_tick); /* Make the matrix */ - for (i = 0; i <= ROWS; i++) { - for (j = 0; j <= COLS - 1; j++ ) { + for (i = 0; i < ROWS; i++) { + for (j = 0; j < COLS; j++) { matrix[i][j].val = -1; matrix[i][j].bold = 0; } } - for (j = 0; j <= COLS - 1; j++) { + for (j = 0; j < COLS; j++) { /* Set up spaces[] array of how many spaces to skip */ spaces[j] = rb->rand() % ROWS + 1; @@ -139,7 +139,7 @@ static void matrix_loop(void) if (count > 4) count = 1; - for (j = 0; j <= COLS - 1; j++) { + for (j = 0; j < COLS; j++) { if (count > updates[j]) { /* New style scrolling */ if (matrix[0][j].val == -1 && matrix[1][j].val == 129 @@ -217,7 +217,7 @@ static void matrix_loop(void) firstcoldone = 1; i++; } - for (i = 1; i <= ROWS; i++) { + for (i = 1; i < ROWS; i++) { if (matrix[i][j].val == 0 || matrix[i][j].bold == 2) { if (matrix[i][j].val == 0) matrix_blit_char(i - 1, j, 20); -- cgit v1.2.3