Skip to content

Commit

Permalink
Merge pull request #35 from mrexodia/fix_leaks
Browse files Browse the repository at this point in the history
fixed some handle/memory leaks and a possible NULL dereference
  • Loading branch information
NtQuery committed Feb 27, 2016
2 parents 93d2a2c + fca8288 commit 0ca2c1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Scylla/FunctionExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ BOOL DumpProcessW(const WCHAR * fileToDump, DWORD_PTR imagebase, DWORD_PTR entry
peFile = new PeParser(imagebase, true);
}

return peFile->dumpProcess(imagebase, entrypoint, fileResult);
bool result = peFile->dumpProcess(imagebase, entrypoint, fileResult);

delete peFile;
return result;
}

BOOL WINAPI ScyllaRebuildFileW(const WCHAR * fileToRebuild, BOOL removeDosStub, BOOL updatePeHeaderChecksum, BOOL createBackup)
{

if (createBackup)
{
if (!ProcessAccessHelp::createBackupFile(fileToRebuild))
Expand Down Expand Up @@ -291,6 +293,5 @@ int WINAPI ScyllaIatFixAutoW(DWORD_PTR iatAddr, DWORD iatSize, DWORD dwProcessId
ProcessAccessHelp::closeProcessHandle();
apiReader.clearAll();


return retVal;
}
2 changes: 2 additions & 0 deletions Scylla/IATSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool IATSearch::findIATAdvanced( DWORD_PTR startAddress, DWORD_PTR* addressIAT,
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"findAPIAddressInIAT2 :: error reading memory");
#endif
delete [] dataBuffer;
return false;
}

Expand Down Expand Up @@ -279,6 +280,7 @@ bool IATSearch::findIATStartAndSize(DWORD_PTR address, DWORD_PTR * addressIAT, D
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"findIATStartAddress :: error reading memory");
#endif
delete [] dataBuffer;
return false;
}

Expand Down
1 change: 1 addition & 0 deletions Scylla/ProcessAccessHelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ LPVOID ProcessAccessHelp::createFileMappingView(const WCHAR * filePath, DWORD ac
#ifdef DEBUG_COMMENTS
Scylla::debugLog.log(L"createFileMappingView :: GetLastError() == ERROR_ALREADY_EXISTS");
#endif
CloseHandle(hMappedFile);
return NULL;
}

Expand Down
5 changes: 5 additions & 0 deletions Scylla/TreeImportExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ bool TreeImportExport::importTreeList(std::map<DWORD_PTR, ImportModuleThunk> & m
}

TiXmlElement * targetElement = doc.FirstChildElement();
if (!targetElement)
{
Sylla::windowLog.log(L"Load Tree :: Error getting first child element in xml %S\r\n", doc.Value());
return false;
}

*addressOEP = ConvertStringToDwordPtr(targetElement->Attribute("oep_va"));
*addressIAT = ConvertStringToDwordPtr(targetElement->Attribute("iat_va"));
Expand Down

0 comments on commit 0ca2c1a

Please sign in to comment.