Merge pull request #1291 from Sierraffinity/master

Fix/document possible division by zero in ConvertScaleParam
This commit is contained in:
GriffinR
2021-01-04 20:48:58 -05:00
committed by GitHub
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -1320,6 +1320,11 @@ void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnim
s16 ConvertScaleParam(s16 scale) s16 ConvertScaleParam(s16 scale)
{ {
s32 val = 0x10000; s32 val = 0x10000;
// UB: possible division by zero
#ifdef UBFIX
if (scale == 0)
return 0;
#endif //UBFIX
return val / scale; return val / scale;
} }
+1 -1
View File
@@ -3042,7 +3042,7 @@ static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite)
if (gSineTable[sprite->data[5] + 64] != 0) if (gSineTable[sprite->data[5] + 64] != 0)
var = 0x10000 / gSineTable[sprite->data[5] + 64]; var = 0x10000 / gSineTable[sprite->data[5] + 64];
else else
var = 0xFFFF; var = 0;
#else #else
var = 0x10000 / gSineTable[sprite->data[5] + 64]; var = 0x10000 / gSineTable[sprite->data[5] + 64];
#endif //UBFIX #endif //UBFIX