summaryrefslogtreecommitdiff
path: root/apps/plugins
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 /apps/plugins
parent4613ffae8a9e2d4281c169078c1d7847536f9f9c (diff)
downloadrockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.zip
rockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.tar.gz
rockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.tar.bz2
rockbox-0fd04941a3b09f2660817ec2903b8520c9d3f33f.tar.xz
matrix plugin: Fix out-of-bounds array access. Unify for-loop style.
Change-Id: I74ec8e559b80bee6c7de02193e943244dcf352c4
Diffstat (limited to 'apps/plugins')
-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 428dc09..087a501 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);