1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

Fix another access outside array bounds.

This commit is contained in:
Lino Mastrodomenico
2019-12-08 22:34:47 +00:00
parent 86caf7ec97
commit e59185cd8d

View File

@@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious a
int FindFunction_WhichIsBroken(int NumberToFind) int FindFunction_WhichIsBroken(int NumberToFind)
{ {
int i = 0; int i = 0;
while (i <= 8) //Notice I should have been in braces while (i < 8) //Notice I should have been in braces
i++; i++;
if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it!
return i; return i;