summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorSergei Antonov <saproj@gmail.com>2013-09-19 17:23:10 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-09-19 17:23:10 +0000
commit6b6aa6d136067a3c9199b4413cdceb652a823b80 (patch)
tree6f66f6cef0dd189bc6a29cfbefcaced62280c93b /ShellPkg
parentc1d932429ef9700a2da64452546be14e92468b07 (diff)
downloadedk2-platforms-6b6aa6d136067a3c9199b4413cdceb652a823b80.tar.xz
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
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
index 8d26c9d93b..7c3aa542b4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
@@ -176,7 +176,9 @@ ShellCommandRunSetVar (
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes2, &Size, Buffer);
- FreePool(Buffer);
+ if (Buffer != NULL) {
+ FreePool(Buffer);
+ }
Attributes = Attributes2;
}
//