From 2db0c4270eda2e652bb39e394aa8a576785a2354 Mon Sep 17 00:00:00 2001 From: lioncash Date: Thu, 24 Jan 2013 08:21:08 -0500 Subject: [PATCH] Fix a potential memory leak on non-windows systems. Also added a FIXME to BPStructs.cpp and BPMemLoader.cpp --- Source/Core/Common/Src/FileUtil.cpp | 12 ++++++++++++ Source/Core/VideoCommon/Src/BPStructs.cpp | 1 + .../Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index d7b248a722..d74c99b7a2 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -512,12 +512,24 @@ bool DeleteDirRecursively(const std::string &directory) if (IsDirectory(newPath)) { if (!DeleteDirRecursively(newPath)) + { + #ifndef _WIN32 + closedir(dirp); + #endif + return false; + } } else { if (!File::Delete(newPath)) + { + #ifndef _WIN32 + closedir(dirp); + #endif + return false; + } } #ifdef _WIN32 diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 9ba2afbbd1..add40d99c3 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -519,6 +519,7 @@ void BPWritten(const BPCmd& bp) for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i) { + // FIXME: Duplicate conditions. if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE) break; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp index 6a17a40eb1..f0674a96cc 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp @@ -137,6 +137,7 @@ void SWBPWritten(int address, int newvalue) for (int i = 0; i < tmem_cfg.preload_tile_info.count; ++i) { + // FIXME: Duplicate conditions if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE) break;