From 7884be106d3952999499da1430b0dc538fdb147a Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 26 Sep 2016 13:24:12 +0200 Subject: [PATCH] Fix closing the directory object if the directory does not exist in findDumpFile --- source/fs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/fs.c b/source/fs.c index bba6832..a71df19 100644 --- a/source/fs.c +++ b/source/fs.c @@ -203,10 +203,15 @@ void findDumpFile(const char *path, char *fileName) { DIR dir; FILINFO info; + FRESULT result; u32 n = 0; - while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0] != 0) + while(true) { + result = f_findfirst(&dir, &info, path, fileName); + + if(result != FR_OK || !info.fname[0]) break; + u32 i = 18, tmp = ++n; @@ -217,5 +222,5 @@ void findDumpFile(const char *path, char *fileName) } } - f_closedir(&dir); + if(result == FR_OK) f_closedir(&dir); } \ No newline at end of file