Fix some memory leaks.

This commit is contained in:
jief 2023-11-21 01:02:27 +01:00
parent 9e2bc77498
commit 544d3cee6d

View File

@ -144,14 +144,13 @@ extern EFI_DXE_SERVICES *gDS;
VOID VOID
PrintMemoryMap() PrintMemoryMap()
{ {
EFI_MEMORY_DESCRIPTOR *MemMap; apd<EFI_MEMORY_DESCRIPTOR*> MemMap;
UINTN MemMapSize; UINTN MemMapSize;
UINTN MapKey, DescriptorSize; UINTN MapKey, DescriptorSize;
UINT32 DescriptorVersion; UINT32 DescriptorVersion;
EFI_STATUS Status; EFI_STATUS Status;
MemMapSize = 0; MemMapSize = 0;
MemMap = NULL;
DescriptorSize = 0; DescriptorSize = 0;
Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion); Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion);
if (Status != EFI_BUFFER_TOO_SMALL) { if (Status != EFI_BUFFER_TOO_SMALL) {
@ -168,8 +167,6 @@ PrintMemoryMap()
} }
OcPrintMemoryMap(MemMapSize, MemMap, DescriptorSize); OcPrintMemoryMap(MemMapSize, MemMap, DescriptorSize);
gBS->FreePool(MemMap);
} }
@ -1131,7 +1128,6 @@ void LOADER_ENTRY::StartLoader()
XBool NoContents = false; XBool NoContents = false;
XStringW infoPlistPath = getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, &NoContents); //it will be fullPath, including dir XStringW infoPlistPath = getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, &NoContents); //it will be fullPath, including dir
DBG("InfoPlistPath=%ls\n", infoPlistPath.wc_str()); DBG("InfoPlistPath=%ls\n", infoPlistPath.wc_str());
TagDict* dict = getInfoPlist(&self.getCloverDir(), infoPlistPath);
// XBool inject = checkOSBundleRequired(dict); // XBool inject = checkOSBundleRequired(dict);
XBool inject = true; XBool inject = true;
if (inject) { if (inject) {
@ -1144,11 +1140,13 @@ void LOADER_ENTRY::StartLoader()
} else { } else {
DBG("Cannot find kext info.plist at '%ls'\n", KextEntry.FileName.wc_str()); DBG("Cannot find kext info.plist at '%ls'\n", KextEntry.FileName.wc_str());
} }
TagDict* dict = getInfoPlist(&self.getCloverDir(), infoPlistPath);
XString8 execpath = getKextExecPath(&self.getCloverDir(), dirPath, KextEntry.FileName, dict, NoContents); XString8 execpath = getKextExecPath(&self.getCloverDir(), dirPath, KextEntry.FileName, dict, NoContents);
if (execpath.notEmpty()) { if (execpath.notEmpty()) {
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, execpath.c_str()); OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, execpath.c_str());
DBG("assign executable as '%s'\n", execpath.c_str()); DBG("assign executable as '%s'\n", execpath.c_str());
} }
if ( dict ) dict->ReleaseTag();
} }
#else #else
@ -2750,7 +2748,7 @@ RefitMainMain (IN EFI_HANDLE ImageHandle,
#endif #endif
} }
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
gBS->Stall(5500000); // to give time to gdb to connect gBS->Stall(2500000); // to give time to gdb to connect
// PauseForKey(); // PauseForKey();
#endif #endif
} }
@ -3525,6 +3523,7 @@ log_technical_bug("not done yet");
delete ThemeX; // do this before destruct_globals_objects() delete ThemeX; // do this before destruct_globals_objects()
FreePool(BlankLine); // Convert BlankLine to XStringW instead. FreePool(BlankLine); // Convert BlankLine to XStringW instead.
TagStruct::EmptyCache();
#ifdef CLOVER_BUILD #ifdef CLOVER_BUILD
destruct_globals_objects(NULL); destruct_globals_objects(NULL);