diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index 7a9756e1f1..e6b2fe4d17 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -567,7 +567,9 @@ BdsExpandPartitionPartialDevicePathToFull ( TempNewDevicePath = CachedDevicePath; CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath); - FreePool(TempNewDevicePath); + if (TempNewDevicePath != NULL) { + FreePool(TempNewDevicePath); + } } else { TempNewDevicePath = CachedDevicePath; CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath); @@ -616,7 +618,9 @@ BdsExpandPartitionPartialDevicePathToFull ( } } - FreePool (CachedDevicePath); + if (CachedDevicePath != NULL) { + FreePool (CachedDevicePath); + } if (BlockIoBuffer != NULL) { FreePool (BlockIoBuffer); }