diff --git a/lib/misc.c b/lib/misc.c index 4164a7b..78d61fc 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -386,7 +386,9 @@ LibInsertToTailOfBootOrder ( VarSize += sizeof(UINT16); NewBootOptionArray = AllocatePool (VarSize); - + if (!NewBootOptionArray) + return EFI_OUT_OF_RESOURCES; + for (Index = 0; Index < ((VarSize/sizeof(UINT16)) - 1); Index++) { NewBootOptionArray[Index] = BootOptionArray[Index]; } @@ -403,9 +405,7 @@ LibInsertToTailOfBootOrder ( VarSize, (VOID*) NewBootOptionArray ); - if (NewBootOptionArray) { - FreePool (NewBootOptionArray); - } + FreePool (NewBootOptionArray); if (BootOptionArray) { FreePool (BootOptionArray); }