From 2af6ef44dc3ae1a5b0ba65239ae84e22af41394b Mon Sep 17 00:00:00 2001 From: Aurora Wright Date: Wed, 6 Sep 2017 02:02:24 +0200 Subject: [PATCH] Add missing fileRead checks --- stage2/arm9/source/fs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stage2/arm9/source/fs.c b/stage2/arm9/source/fs.c index 9b3d7ab..2514dbb 100644 --- a/stage2/arm9/source/fs.c +++ b/stage2/arm9/source/fs.c @@ -26,16 +26,17 @@ bool mountCtrNand(void) u32 fileRead(void *dest, const char *path, u32 size, u32 maxSize) { FIL file; + FRESULT result = FR_OK; u32 ret = 0; if(f_open(&file, path, FA_READ) != FR_OK) return ret; if(!size) size = f_size(&file); if(!maxSize || size <= maxSize) - f_read(&file, dest, size, (unsigned int *)&ret); - f_close(&file); + result = f_read(&file, dest, size, (unsigned int *)&ret); + result |= f_close(&file); - return ret; + return result == FR_OK ? ret : 0; } bool fileWrite(const void *buffer, const char *path, u32 size)