From 1f2d6a78f263935744aea35e577455748c87757b Mon Sep 17 00:00:00 2001 From: d0k3 Date: Tue, 19 Sep 2017 15:20:10 +0200 Subject: [PATCH] Prevent AR dumps from triggering exceptions --- source/game/nds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/game/nds.c b/source/game/nds.c index 4eb6007..c1b76ea 100644 --- a/source/game/nds.c +++ b/source/game/nds.c @@ -109,8 +109,9 @@ u32 FindNitroRomDir(u32 dirid, u32* fileid, u8** fnt_entry, TwlHeader* hdr, u8* // check subtable / directory validity u32 fid = *fileid; - for (u8* entry = *fnt_entry; *entry; entry = FNT_ENTRY_NEXT(entry)) { + for (u8* entry = *fnt_entry;; entry = FNT_ENTRY_NEXT(entry)) { if (entry >= fnt + hdr->fnt_size) return 1; // corrupt subtable + if (!*entry) break; // end of table reached if (fat_lut[fid].start_address > fat_lut[fid].end_address) return 1; // corrupt fat if (!FNT_ENTRY_ISDIR(entry)) fid++; }