diff options
author | Sierraffinity <sierra@domoreaweso.me> | 2021-01-04 16:26:28 -0800 |
---|---|---|
committer | Sierraffinity <sierra@domoreaweso.me> | 2021-01-04 16:26:28 -0800 |
commit | 67a656a4df326ebfcbca48c76efdc4fc39554093 (patch) | |
tree | 71a9635fa703b17883bd180745b850f2d8d9cf21 /gflib/sprite.c | |
parent | b88922daea18aa192e1712d6fb170487ddc014b5 (diff) |
Fix/document possible division by zero in ConvertScaleParam
Diffstat (limited to 'gflib/sprite.c')
-rw-r--r-- | gflib/sprite.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gflib/sprite.c b/gflib/sprite.c index c7e3d09a3..e36c53721 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -1319,8 +1319,18 @@ void ApplyAffineAnimFrameRelativeAndUpdateMatrix(u8 matrixNum, struct AffineAnim s16 ConvertScaleParam(s16 scale) { + s16 ret; s32 val = 0x10000; - return val / scale; + // UB: possible division by zero +#ifdef UBFIX + if (scale != 0) + ret = val / scale; + else + ret = 0; +#else + ret = val / scale; +#endif //UBFIX + return ret; } void GetAffineAnimFrame(u8 matrixNum, struct Sprite *sprite, struct AffineAnimFrameCmd *frameCmd) |