From 013ffe654dccd4c43e849a66adf8f540ae3de21c Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Fri, 19 Oct 2018 18:41:54 -0600 Subject: [PATCH] Run closedir(isDir); after checking isDir --- arm9/source/fileOperations.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arm9/source/fileOperations.cpp b/arm9/source/fileOperations.cpp index 4d2239c..31abcd0 100644 --- a/arm9/source/fileOperations.cpp +++ b/arm9/source/fileOperations.cpp @@ -47,6 +47,9 @@ int fcopy(const char *sourcePath, const char *destinationPath) DIR *isDir = opendir (sourcePath); if (isDir != NULL) { + closedir(isDir); + + // Source path is a directory chdir(sourcePath); vector dirContents; getDirectoryContents(dirContents); @@ -63,6 +66,9 @@ int fcopy(const char *sourcePath, const char *destinationPath) chdir (".."); return 1; } else { + closedir(isDir); + + // Source path is a file FILE* sourceFile = fopen(sourcePath, "rb"); off_t fsize = 0; if (sourceFile) { @@ -119,5 +125,4 @@ int fcopy(const char *sourcePath, const char *destinationPath) return -1; } - closedir(isDir); }