// find the current directory
DevicePathAsString = DevicePathToStr(SelfLoadedImage->FilePath);
-// Print(L"DevicePathAsString is '%s'\n", DevicePathAsString);
CleanUpPathNameSlashes(DevicePathAsString);
- if (SelfDirPath != NULL)
- FreePool(SelfDirPath);
+ MyFreePool(SelfDirPath);
SelfDirPath = FindPath(DevicePathAsString);
-// Print(L"SelfDirPath is '%s'\n", SelfDirPath);
-// PauseForKey();
- FreePool(DevicePathAsString);
+ MyFreePool(DevicePathAsString);
return FinishInitRefitLib();
}
{
UINTN i;
- if (*ElementCount > 0) {
+ if ((*ElementCount > 0) && (**ListPtr != NULL)) {
for (i = 0; i < *ElementCount; i++) {
// TODO: call a user-provided routine for each element here
- FreePool((*ListPtr)[i]);
+ MyFreePool((*ListPtr)[i]);
}
- FreePool(*ListPtr);
+ MyFreePool(*ListPtr);
}
-}
+} // VOID FreeList()
//
// firmware device path discovery
PathList[PathCount++] = AppendDevicePath(DevicePath, LegacyLoaderMediaPath);
}
- FreePool(Handles);
+ MyFreePool(Handles);
if (HardcodedPathList) {
for (HardcodedIndex = 0; HardcodedPathList[HardcodedIndex] && PathCount < MaxPaths; HardcodedIndex++)
} // switch()
}
-static VOID ScanVolume(IN OUT REFIT_VOLUME *Volume)
+VOID ScanVolume(IN OUT REFIT_VOLUME *Volume)
{
EFI_STATUS Status;
EFI_DEVICE_PATH *DevicePath, *NextDevicePath;
UINT8 *SectorBuffer1, *SectorBuffer2;
UINTN SectorSum, i;
- FreePool(Volumes);
+ MyFreePool(Volumes);
Volumes = NULL;
VolumesCount = 0;
if (Volume->DeviceHandle == SelfLoadedImage->DeviceHandle)
SelfVolume = Volume;
}
- FreePool(Handles);
+ MyFreePool(Handles);
if (SelfVolume == NULL)
Print(L"WARNING: SelfVolume not found");
break;
}
- FreePool(SectorBuffer1);
- FreePool(SectorBuffer2);
+ MyFreePool(SectorBuffer1);
+ MyFreePool(SectorBuffer2);
}
}
// free pointer from last call
if (*DirEntry != NULL) {
- FreePool(*DirEntry);
- *DirEntry = NULL;
+ FreePool(*DirEntry);
+ *DirEntry = NULL;
}
// read next directory entry
CHAR16 *OnePattern;
if (DirIter->LastFileInfo != NULL) {
- FreePool(DirIter->LastFileInfo);
- DirIter->LastFileInfo = NULL;
+ FreePool(DirIter->LastFileInfo);
+ DirIter->LastFileInfo = NULL;
}
if (EFI_ERROR(DirIter->LastStatus))
EFI_STATUS DirIterClose(IN OUT REFIT_DIR_ITER *DirIter)
{
- if (DirIter->LastFileInfo != NULL) {
- FreePool(DirIter->LastFileInfo);
- DirIter->LastFileInfo = NULL;
- }
- if (DirIter->CloseDirHandle)
- refit_call1_wrapper(DirIter->DirHandle->Close, DirIter->DirHandle);
+ if (DirIter->LastFileInfo != NULL) {
+ FreePool(DirIter->LastFileInfo);
+ DirIter->LastFileInfo = NULL;
+ }
+ if (DirIter->CloseDirHandle)
+ refit_call1_wrapper(DirIter->DirHandle->Close, DirIter->DirHandle);
return DirIter->LastStatus;
}
while ((!Found) && (StartPoint < NumCompares)) {
Found = (StrnCmp(SmallCopy, &BigCopy[StartPoint++], SmallLen) == 0);
} // while
- FreePool(SmallCopy);
- FreePool(BigCopy);
+ MyFreePool(SmallCopy);
+ MyFreePool(BigCopy);
} // if
return (Found);
} // if (*First != NULL)
if (Second != NULL)
StrCat(NewString, Second);
- FreePool(*First);
+ MyFreePool(*First);
*First = NewString;
} else {
Print(L"Error! Unable to allocate memory in MergeStrings()!\n");
return Found;
} // BOOLEAN IsIn()
+// Implement FreePool the way it should have been done to begin with, so that
+// it doesn't throw an ASSERT message if fed a NULL pointer....
+VOID MyFreePool(IN OUT VOID *Pointer) {
+ if (Pointer != NULL)
+ FreePool(Pointer);
+}
+
static EFI_GUID AppleRemovableMediaGuid = APPLE_REMOVABLE_MEDIA_PROTOCOL_GUID;
// Eject all removable media.
if (!EFI_ERROR(Status))
Ejected++;
}
- FreePool(Handles);
+ MyFreePool(Handles);
return (Ejected > 0);
} // VOID EjectMedia()