summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.richards@comcast.net>2019-10-04 00:58:47 -0400
committerhuderlem <huderlem@gmail.com>2019-10-05 09:24:57 -0500
commita6847ca1d938f6f4f317d88b0f656682a974c6d9 (patch)
treedcd4de229af8b5af2e223abe96443fcf75cb787d /src
parent48e54ae387b81a20cb7a123d4a0639b332631ac9 (diff)
Note overflow in ModifyStatByNature
Diffstat (limited to 'src')
-rw-r--r--src/pokemon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pokemon.c b/src/pokemon.c
index da659b10d..55f9a93f3 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -5724,9 +5724,9 @@ u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
switch (gNatureStatTable[nature][statIndex - 1])
{
case 1:
- return (u16)(n * 110) / 100;
+ return (u16)(n * 110) / 100; // NOTE: will overflow for n > 595 because the intermediate value is cast to u16 before the division. Fix by removing (u16) cast
case -1:
- return (u16)(n * 90) / 100;
+ return (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
}
return n;