From a34aba3b726c47832b475618d03a8d71f20fadec Mon Sep 17 00:00:00 2001
From: yellows8 <yellows8@users.noreply.github.com>
Date: Fri, 3 Apr 2020 00:23:04 -0400
Subject: [PATCH] Fixed issue with the fs/save example where the
 FsSaveDataInfoReader was not closed when a save was found successfully.

---
 fs/save/source/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/save/source/main.c b/fs/save/source/main.c
index bf039c3..d465778 100644
--- a/fs/save/source/main.c
+++ b/fs/save/source/main.c
@@ -11,6 +11,7 @@ Result get_save(u64 *application_id, AccountUid *uid) {
     FsSaveDataInfoReader reader;
     s64 total_entries=0;
     FsSaveDataInfo info;
+    bool found=0;
 
     rc = fsOpenSaveDataInfoReader(&reader, FsSaveDataSpaceId_User);//See libnx fs.h.
     if (R_FAILED(rc)) {
@@ -26,13 +27,14 @@ Result get_save(u64 *application_id, AccountUid *uid) {
         if (info.save_data_type == FsSaveDataType_Account) {//Filter by FsSaveDataType_Account, however note that FsSaveDataSpaceId_User can have non-FsSaveDataType_Account.
             *application_id = info.application_id;
             *uid = info.uid;
-            return 0;
+            found = 1;
+            break;
         }
     }
 
     fsSaveDataInfoReaderClose(&reader);
 
-    if (R_SUCCEEDED(rc)) return MAKERESULT(Module_Libnx, LibnxError_NotFound);
+    if (R_SUCCEEDED(rc) && !found) return MAKERESULT(Module_Libnx, LibnxError_NotFound);
 
     return rc;
 }