ShellPkg: Handle pool allocation failure

If AllocateZeroPool() returns NULL,
GetVariable() will return EFI_BUFFER_TOO_SMALL,
FreePool() will receive NULL.
So check for NULL before FreePool().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14688 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Sergei Antonov 2013-09-19 17:23:10 +00:00 committed by jcarsey
parent c1d932429e
commit 6b6aa6d136
1 changed files with 3 additions and 1 deletions

View File

@ -176,7 +176,9 @@ ShellCommandRunSetVar (
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes2, &Size, Buffer);
if (Buffer != NULL) {
FreePool(Buffer);
}
Attributes = Attributes2;
}
//