summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-29 16:40:02 +0200
committerGitHub <[email protected]>2019-05-29 16:40:02 +0200
commit20bdc3bc2a4ec06d6f7c2535927056bb12517992 (patch)
treebbdb20ecd07784280c70a0610776d1498181097b
parent5d3905d4d4bdeb476f8b5bce11ad9893c0dc881d (diff)
parent42d57bbe00c99fe3cf6a0819b9a2bf4bf3b64873 (diff)
downloadraylib-20bdc3bc2a4ec06d6f7c2535927056bb12517992.tar.gz
raylib-20bdc3bc2a4ec06d6f7c2535927056bb12517992.zip
Merge pull request #854 from ChrisDill/master
Added array bounds check to textures_bunnymark
-rw-r--r--examples/textures/textures_bunnymark.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c
index 6b91d646..784417d2 100644
--- a/examples/textures/textures_bunnymark.c
+++ b/examples/textures/textures_bunnymark.c
@@ -54,13 +54,16 @@ int main(void)
// Create more bunnies
for (int i = 0; i < 100; i++)
{
- bunnies[bunniesCount].position = GetMousePosition();
- bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f;
- bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f;
- bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240),
+ if (bunniesCount < MAX_BUNNIES)
+ {
+ bunnies[bunniesCount].position = GetMousePosition();
+ bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f;
+ bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f;
+ bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240),
GetRandomValue(80, 240),
GetRandomValue(100, 240), 255 };
- bunniesCount++;
+ bunniesCount++;
+ }
}
}