summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2012-12-18 23:35:28 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2012-12-18 23:35:28 -0600
commit2db4549174620aa130ef012af26c2e1760c4928c (patch)
tree17bb6a25c973d030bfb37fe31326ad0462e867fa /Source/Core/Common/Src/FileUtil.cpp
parent16ac7803f15a52973a90b94fd630ffacd7364b05 (diff)
Fix a memory leak based on Lioncash's patches.
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index 691685e99d..77aac45418 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -299,7 +299,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
ERROR_LOG(COMMON,
"Copy: failed reading from source, %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
- return false;
+ goto bail;
}
}
@@ -310,13 +310,19 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
ERROR_LOG(COMMON,
"Copy: failed writing to output, %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
- return false;
+ goto bail;
}
}
// close flushs
fclose(input);
fclose(output);
return true;
+bail:
+ if (input)
+ fclose(input);
+ if (output)
+ fclose(output);
+ return false;
#endif
}