Skip to content

Commit 0ca2c1a

Browse files
committed
Merge pull request #35 from mrexodia/fix_leaks
fixed some handle/memory leaks and a possible NULL dereference
2 parents 93d2a2c + fca8288 commit 0ca2c1a

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Scylla/FunctionExport.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ BOOL DumpProcessW(const WCHAR * fileToDump, DWORD_PTR imagebase, DWORD_PTR entry
4040
peFile = new PeParser(imagebase, true);
4141
}
4242

43-
return peFile->dumpProcess(imagebase, entrypoint, fileResult);
43+
bool result = peFile->dumpProcess(imagebase, entrypoint, fileResult);
44+
45+
delete peFile;
46+
return result;
4447
}
4548

4649
BOOL WINAPI ScyllaRebuildFileW(const WCHAR * fileToRebuild, BOOL removeDosStub, BOOL updatePeHeaderChecksum, BOOL createBackup)
4750
{
48-
4951
if (createBackup)
5052
{
5153
if (!ProcessAccessHelp::createBackupFile(fileToRebuild))
@@ -291,6 +293,5 @@ int WINAPI ScyllaIatFixAutoW(DWORD_PTR iatAddr, DWORD iatSize, DWORD dwProcessId
291293
ProcessAccessHelp::closeProcessHandle();
292294
apiReader.clearAll();
293295

294-
295296
return retVal;
296297
}

Scylla/IATSearch.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bool IATSearch::findIATAdvanced( DWORD_PTR startAddress, DWORD_PTR* addressIAT,
5151
#ifdef DEBUG_COMMENTS
5252
Scylla::debugLog.log(L"findAPIAddressInIAT2 :: error reading memory");
5353
#endif
54+
delete [] dataBuffer;
5455
return false;
5556
}
5657

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

Scylla/ProcessAccessHelp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ LPVOID ProcessAccessHelp::createFileMappingView(const WCHAR * filePath, DWORD ac
601601
#ifdef DEBUG_COMMENTS
602602
Scylla::debugLog.log(L"createFileMappingView :: GetLastError() == ERROR_ALREADY_EXISTS");
603603
#endif
604+
CloseHandle(hMappedFile);
604605
return NULL;
605606
}
606607

Scylla/TreeImportExport.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ bool TreeImportExport::importTreeList(std::map<DWORD_PTR, ImportModuleThunk> & m
4040
}
4141

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

4449
*addressOEP = ConvertStringToDwordPtr(targetElement->Attribute("oep_va"));
4550
*addressIAT = ConvertStringToDwordPtr(targetElement->Attribute("iat_va"));

0 commit comments

Comments
 (0)