summaryrefslogtreecommitdiff
path: root/plugins/Db_autobackups
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-09 18:51:46 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-09 18:51:46 +0000
commit206ebe56652d10d1a91f1b9ce4299834f272f414 (patch)
tree94c8f98a02ee5873e196fd8d53ad873a5af7963e /plugins/Db_autobackups
parent56c7e019fd21d3c1d84491bdf6219747702b4b47 (diff)
fix handle leak
git-svn-id: http://svn.miranda-ng.org/main/trunk@16255 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db_autobackups')
-rw-r--r--plugins/Db_autobackups/src/backup.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index c9415a1a2d..f10d2d3806 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -81,12 +81,13 @@ TCHAR* DoubleSlash(TCHAR *sorce)
bool MakeZip_Dir(LPCSTR szDir, LPCTSTR szDest, LPCSTR /* szDbName */, HWND progress_dialog)
{
zipFile hZip = zipOpen2_64(szDest, APPEND_STATUS_CREATE, NULL, NULL);
+ if (!hZip)
+ return false;
+
zip_fileinfo fi = { 0 };
- auto folder = fs::path(szDir);
- auto it = fs::recursive_directory_iterator(folder);
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
size_t i = 0;
- for (it; it != fs::recursive_directory_iterator(); ++it)
+ for (auto it = fs::recursive_directory_iterator(fs::path(szDir)); it != fs::recursive_directory_iterator(); ++it)
{
const auto& file = it->path();
if (!fs::is_directory(file) && !strstr(std::string(file).c_str(), _T2A(szDest)))
@@ -101,15 +102,12 @@ bool MakeZip_Dir(LPCSTR szDir, LPCTSTR szDest, LPCSTR /* szDbName */, HWND progr
{
DWORD dwRead;
uint8_t buf[(256 * 1024)];
- while (ReadFile(hSrc, buf, sizeof(buf), &dwRead, nullptr) && dwRead)
- {
- if (zipWriteInFileInZip(hZip, buf, dwRead) != ZIP_OK)
- break;
- }
+ while (ReadFile(hSrc, buf, sizeof(buf), &dwRead, nullptr) && dwRead && !zipWriteInFileInZip(hZip, buf, dwRead));
zipCloseFileInZip(hZip);
}
i++;
SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(i % 100), 0);
+ CloseHandle(hSrc);
}
}
}