From 02f5abb87701d67ef883992ef89b0948e5ae21bc Mon Sep 17 00:00:00 2001 From: d0k3 Date: Thu, 15 Mar 2018 00:57:41 +0100 Subject: [PATCH] Fix too menu entries in dir crashing GM9 ... happened when there where more than 1024 entries. --- arm9/source/filesys/fsdrive.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arm9/source/filesys/fsdrive.c b/arm9/source/filesys/fsdrive.c index b4c7486..6cb81c0 100644 --- a/arm9/source/filesys/fsdrive.c +++ b/arm9/source/filesys/fsdrive.c @@ -142,12 +142,12 @@ bool GetDirContentsWorker(DirStruct* contents, char* fpath, int fnsize, const ch entry->size = fno.fsize; } entry->marked = 0; - if (contents->n_entries >= MAX_DIR_ENTRIES) { - ret = true; // Too many entries, still okay - break; + if (!recursive || (entry->type != T_DIR)) { + if (++(contents->n_entries) >= MAX_DIR_ENTRIES) { + ret = true; // Too many entries, still okay if we stop here + break; + } } - if (!recursive || (entry->type != T_DIR)) - contents->n_entries++; } if (recursive && (fno.fattrib & AM_DIR)) { if (!GetDirContentsWorker(contents, fpath, fnsize, pattern, recursive))