Merge pull request #11 from JohnLaTwC/patch-1

Close handle on error exits to avoid leaking handle
This commit is contained in:
batsec
2021-10-09 00:05:26 +01:00
committed by GitHub
+6 -1
View File
@@ -119,6 +119,7 @@ BOOL ReadFileToBuffer(
if (dwSize == INVALID_FILE_SIZE)
{
pdModule->ErrorMsg = L"Failed to get DLL file size";
pCloseHandle(hFile);
return FALSE;
}
@@ -132,6 +133,7 @@ BOOL ReadFileToBuffer(
if (pdModule->pbDllData == NULL)
{
pdModule->ErrorMsg = L"Failed to allocate memory for DLL data";
pCloseHandle(hFile);
return FALSE;
}
@@ -143,6 +145,9 @@ BOOL ReadFileToBuffer(
NULL))
{
pdModule->ErrorMsg = L"Failed to read data from DLL file";
pCloseHandle(hFile);
// TODO: need to Free buffer on error: e.g. pVirtualFree(pdModule->pbDllData);
return FALSE;
}
@@ -305,4 +310,4 @@ BOOL ConcealLibrary(
pdModule->ErrorMsg = L"Not implemented yet, sorry";
return FALSE;
}
}