From bafbf9240d0f91ee3c38ca4652e3c54b9c503c9b Mon Sep 17 00:00:00 2001 From: Sierraffinity Date: Sat, 26 Dec 2020 17:47:36 -0800 Subject: Add UBFIX for null deref in sub_80D08CC --- src/pokemon_storage_system.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index db8f3d2bb..4be1cf729 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -8408,8 +8408,13 @@ static void sub_80D08CC(void) for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition); - + // UB: possible null dereference +#ifdef UBFIX + if (boxMon != NULL) + sMoveMonsPtr->boxMons[monArrayId] = *boxMon; +#else sMoveMonsPtr->boxMons[monArrayId] = *boxMon; +#endif monArrayId++; boxPosition++; } -- cgit v1.2.3