From b82098a29ef35dad3d4ebfb2c88f858c6807ac6d Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 22 Nov 2015 18:36:05 +0100 Subject: [PATCH] Fixed possible memory leak. --- src/OSSupport_Win32.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index 1a483f5..133f3ad 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -843,12 +843,15 @@ QString MUtils::OS::get_file_path(const int &fd) const DWORD len = g_getFilePath_prt(handle, NULL, 0, FILE_NAME_OPENED); if (len > 0) { - wchar_t *const buffer = (wchar_t*) _malloca(sizeof(wchar_t) * len); - const DWORD ret = g_getFilePath_prt(handle, buffer, len, FILE_NAME_OPENED); - if ((ret > 0) && (ret < len)) + if (wchar_t *const buffer = (wchar_t*)_malloca(sizeof(wchar_t) * len)) { - const QString path(MUTILS_QSTR(buffer)); - return path.startsWith(QLatin1String("\\\\?\\")) ? path.mid(4) : path; + const DWORD ret = g_getFilePath_prt(handle, buffer, len, FILE_NAME_OPENED); + if ((ret > 0) && (ret < len)) + { + const QString path(MUTILS_QSTR(buffer)); + return path.startsWith(QLatin1String("\\\\?\\")) ? path.mid(4) : path; + } + _freea(buffer); } } }