Fixed possible memory leak.

This commit is contained in:
LoRd_MuldeR 2015-11-22 18:36:05 +01:00
parent ae605d9d1e
commit b82098a29e

View File

@ -843,13 +843,16 @@ QString MUtils::OS::get_file_path(const int &fd)
const DWORD len = g_getFilePath_prt(handle, NULL, 0, FILE_NAME_OPENED); const DWORD len = g_getFilePath_prt(handle, NULL, 0, FILE_NAME_OPENED);
if (len > 0) if (len > 0)
{ {
wchar_t *const buffer = (wchar_t*) _malloca(sizeof(wchar_t) * len); if (wchar_t *const buffer = (wchar_t*)_malloca(sizeof(wchar_t) * len))
{
const DWORD ret = g_getFilePath_prt(handle, buffer, len, FILE_NAME_OPENED); const DWORD ret = g_getFilePath_prt(handle, buffer, len, FILE_NAME_OPENED);
if ((ret > 0) && (ret < len)) if ((ret > 0) && (ret < len))
{ {
const QString path(MUTILS_QSTR(buffer)); const QString path(MUTILS_QSTR(buffer));
return path.startsWith(QLatin1String("\\\\?\\")) ? path.mid(4) : path; return path.startsWith(QLatin1String("\\\\?\\")) ? path.mid(4) : path;
} }
_freea(buffer);
}
} }
} }