summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2012-06-03 23:37:33 +0200
committerBertrik Sikken <bertrik@sikken.nl>2012-06-03 23:37:33 +0200
commit0fd04941a3b09f2660817ec2903b8520c9d3f33f (patch)
tree98ebabe3cd788845f8861579bda800d2dbe597d8
parent4613ffae8a9e2d4281c169078c1d7847536f9f9c (diff)
downloadrockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.tar.gz
rockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.zip
matrix plugin: Fix out-of-bounds array access. Unify for-loop style.
Change-Id: I74ec8e559b80bee6c7de02193e943244dcf352c4
-rw-r--r--apps/plugins/matrix.c10
1 files changed, 5 insertions, 5 deletions
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) {
88 rb->srand(*rb->current_tick); 88 rb->srand(*rb->current_tick);
89 89
90 /* Make the matrix */ 90 /* Make the matrix */
91 for (i = 0; i <= ROWS; i++) { 91 for (i = 0; i < ROWS; i++) {
92 for (j = 0; j <= COLS - 1; j++ ) { 92 for (j = 0; j < COLS; j++) {
93 matrix[i][j].val = -1; 93 matrix[i][j].val = -1;
94 matrix[i][j].bold = 0; 94 matrix[i][j].bold = 0;
95 } 95 }
96 } 96 }
97 97
98 for (j = 0; j <= COLS - 1; j++) { 98 for (j = 0; j < COLS; j++) {
99 /* Set up spaces[] array of how many spaces to skip */ 99 /* Set up spaces[] array of how many spaces to skip */
100 spaces[j] = rb->rand() % ROWS + 1; 100 spaces[j] = rb->rand() % ROWS + 1;
101 101
@@ -139,7 +139,7 @@ static void matrix_loop(void)
139 if (count > 4) 139 if (count > 4)
140 count = 1; 140 count = 1;
141 141
142 for (j = 0; j <= COLS - 1; j++) { 142 for (j = 0; j < COLS; j++) {
143 if (count > updates[j]) { 143 if (count > updates[j]) {
144 /* New style scrolling */ 144 /* New style scrolling */
145 if (matrix[0][j].val == -1 && matrix[1][j].val == 129 145 if (matrix[0][j].val == -1 && matrix[1][j].val == 129
@@ -217,7 +217,7 @@ static void matrix_loop(void)
217 firstcoldone = 1; 217 firstcoldone = 1;
218 i++; 218 i++;
219 } 219 }
220 for (i = 1; i <= ROWS; i++) { 220 for (i = 1; i < ROWS; i++) {
221 if (matrix[i][j].val == 0 || matrix[i][j].bold == 2) { 221 if (matrix[i][j].val == 0 || matrix[i][j].bold == 2) {
222 if (matrix[i][j].val == 0) 222 if (matrix[i][j].val == 0)
223 matrix_blit_char(i - 1, j, 20); 223 matrix_blit_char(i - 1, j, 20);