mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-01 12:53:27 +01:00
Why did I put the FreePool parameter as const. That's stupid !
You must never free a const pointer, by definition.
This commit is contained in:
parent
22d277d1e4
commit
187400d0ae
@ -478,10 +478,13 @@ ReallocateReservedPool (
|
|||||||
@param Buffer Pointer to the buffer to free.
|
@param Buffer Pointer to the buffer to free.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
/*
|
||||||
|
* Jief : One day, I put JCONST. This is wrong !!! You must never free a ptr that's const.
|
||||||
|
*/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
FreePool(
|
FreePool(
|
||||||
IN JCONST VOID *Buffer
|
IN VOID *Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -681,7 +681,8 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
|
|||||||
// Check for ia.log - InstallESD/createinstallmedia/startosinstall
|
// Check for ia.log - InstallESD/createinstallmedia/startosinstall
|
||||||
// Implemented by Sherlocks
|
// Implemented by Sherlocks
|
||||||
if (OSVersion.isEmpty()) {
|
if (OSVersion.isEmpty()) {
|
||||||
CONST CHAR8 *s, *fileBuffer;
|
CONST CHAR8 *s;
|
||||||
|
UINT8* fileBuffer;
|
||||||
// CHAR8 *Res5 = (__typeof__(Res5))AllocateZeroPool(5);
|
// CHAR8 *Res5 = (__typeof__(Res5))AllocateZeroPool(5);
|
||||||
// CHAR8 *Res6 = (__typeof__(Res6))AllocateZeroPool(6);
|
// CHAR8 *Res6 = (__typeof__(Res6))AllocateZeroPool(6);
|
||||||
// CHAR8 *Res7 = (__typeof__(Res7))AllocateZeroPool(7);
|
// CHAR8 *Res7 = (__typeof__(Res7))AllocateZeroPool(7);
|
||||||
@ -696,10 +697,10 @@ MacOsVersion GetOSVersion(int LoaderType, const EFI_GUID& APFSTargetUUID, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (FileExists (Volume->RootDir, InstallerLog)) {
|
if (FileExists (Volume->RootDir, InstallerLog)) {
|
||||||
Status = egLoadFile(Volume->RootDir, InstallerLog.wc_str(), (UINT8 **)&fileBuffer, &fileLen);
|
Status = egLoadFile(Volume->RootDir, InstallerLog.wc_str(), &fileBuffer, &fileLen);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
XString8 targetString;
|
XString8 targetString;
|
||||||
targetString.strncpy(fileBuffer, fileLen);
|
targetString.strncpy((CHAR8*)fileBuffer, fileLen);
|
||||||
// s = SearchString(targetString, fileLen, "Running OS Build: Mac OS X ", 27);
|
// s = SearchString(targetString, fileLen, "Running OS Build: Mac OS X ", 27);
|
||||||
s = AsciiStrStr(targetString.c_str(), "Running OS Build: Mac OS X ");
|
s = AsciiStrStr(targetString.c_str(), "Running OS Build: Mac OS X ");
|
||||||
if (s[31] == ' ') {
|
if (s[31] == ' ') {
|
||||||
|
@ -125,8 +125,8 @@ EFI_STATUS Status = EFI_NOT_FOUND;
|
|||||||
}
|
}
|
||||||
TestTheme.setEmpty();
|
TestTheme.setEmpty();
|
||||||
}
|
}
|
||||||
FreePool(ChosenTheme);
|
//FreePool(ChosenTheme); // ChosenTheme is an argument passed here, so the callee is "own" that memory.
|
||||||
ChosenTheme = NULL;
|
//ChosenTheme = NULL; // Why is this bad pratice : it's assuming that ChosenTheme was dynamically allocated and freeable. What is this the content of an XString ?
|
||||||
}
|
}
|
||||||
// Try to get theme from settings
|
// Try to get theme from settings
|
||||||
if (ThemeDict == NULL) {
|
if (ThemeDict == NULL) {
|
||||||
@ -204,7 +204,8 @@ finish:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ChosenTheme != NULL) {
|
if (ChosenTheme != NULL) {
|
||||||
FreePool(ChosenTheme);
|
//FreePool(ChosenTheme); // ChosenTheme is an argument passed here, so the callee is "own" that memory.
|
||||||
|
// Why is this bad pratice : it's assuming that ChosenTheme was dynamically allocated and freeable. What is this the content of an XString ?
|
||||||
}
|
}
|
||||||
if (!ThemeX->TypeSVG) {
|
if (!ThemeX->TypeSVG) {
|
||||||
ThemeX->PrepareFont();
|
ThemeX->PrepareFont();
|
||||||
|
@ -3030,7 +3030,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
|||||||
if (!GlobalConfig.isFastBoot()) {
|
if (!GlobalConfig.isFastBoot()) {
|
||||||
if (gThemeNeedInit) {
|
if (gThemeNeedInit) {
|
||||||
UINTN Size = 0;
|
UINTN Size = 0;
|
||||||
InitTheme((CHAR8*)GetNvramVariable(L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size));
|
CHAR8* ChoosenTheme = (CHAR8*)GetNvramVariable(L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size);
|
||||||
|
InitTheme(ChoosenTheme);
|
||||||
|
FreePool(ChoosenTheme);
|
||||||
gThemeNeedInit = false;
|
gThemeNeedInit = false;
|
||||||
} else if (GlobalConfig.gThemeChanged) {
|
} else if (GlobalConfig.gThemeChanged) {
|
||||||
DBG("change theme\n");
|
DBG("change theme\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user