diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:38:11 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:38:48 +0100 |
commit | 366f00a3d3dc6517e7dcb1bbebb887c4f795320b (patch) | |
tree | 1a71055ae9d196956d68490eb3926a874decff07 /apps/plugins | |
parent | ab71b9e33403f503cf3fc15d6df612bba51d22d6 (diff) | |
download | rockbox-366f00a3d3dc6517e7dcb1bbebb887c4f795320b.tar.gz rockbox-366f00a3d3dc6517e7dcb1bbebb887c4f795320b.zip |
plugins: fix out of bounds read in chopper
GCC complains about this when compiling with UBSan.
Change-Id: I4bd8ff2b47882ab95620dc7750a9a80f823cc2ea
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/chopper.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 70763a1b67..392b840317 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c | |||
@@ -523,19 +523,18 @@ static void chopAddBlock(int x,int y,int sx,int sy, int indexOverride) | |||
523 | 523 | ||
524 | static void chopAddParticle(int x,int y,int sx,int sy) | 524 | static void chopAddParticle(int x,int y,int sx,int sy) |
525 | { | 525 | { |
526 | int i=0; | 526 | for(int i = 0; i < NUMBER_OF_PARTICLES; ++i) |
527 | 527 | { | |
528 | while(mParticles[i].bIsActive && i < NUMBER_OF_PARTICLES) | 528 | if(!mParticles[i].bIsActive) |
529 | i++; | 529 | { |
530 | 530 | mParticles[i].bIsActive = 1; | |
531 | if(i==NUMBER_OF_PARTICLES) | 531 | mParticles[i].iWorldX = x; |
532 | return; | 532 | mParticles[i].iWorldY = y; |
533 | 533 | mParticles[i].iSpeedX = sx; | |
534 | mParticles[i].bIsActive = 1; | 534 | mParticles[i].iSpeedY = sy; |
535 | mParticles[i].iWorldX = x; | 535 | return; |
536 | mParticles[i].iWorldY = y; | 536 | } |
537 | mParticles[i].iSpeedX = sx; | 537 | } |
538 | mParticles[i].iSpeedY = sy; | ||
539 | } | 538 | } |
540 | 539 | ||
541 | static void chopGenerateBlockIfNeeded(void) | 540 | static void chopGenerateBlockIfNeeded(void) |