From e3d77e8086daf0fa2fe73e51fca3ff44623aedf6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 31 Oct 2022 17:30:51 +1000 Subject: [PATCH] Avoid some potential UB in bgBuildTables --- src/game/bg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/bg.c b/src/game/bg.c index 0e286bb34..fcc914586 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -3251,7 +3251,10 @@ void bgBuildTables(s32 stagenum) inflatedsize = (inflatedsize | 0xf) + 1; // Load and inflate section 3 -#if VERSION >= VERSION_NTSC_FINAL +#ifdef AVOID_UB + section3 = mempAlloc(inflatedsize + section3compsize, MEMPOOL_STAGE); + scratch = section3 + inflatedsize; +#elif VERSION >= VERSION_NTSC_FINAL section3 = mempAlloc(inflatedsize + 0x8000, MEMPOOL_STAGE); scratch = section3 + 0x8000; #else