lib/misc: avoid NULL dereference in LibInsertToTailOfBootOrder
AllocatePool() may return NULL. We must check the return value before dereferencing it. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
70402aa91d
commit
500c10f191
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user