Index: ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c
===================================================================
--- ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c	(revision 14678)
+++ ShellPkg/Library/UefiShellDebug1CommandsLib/SetVar.c	(working copy)
@@ -176,7 +176,9 @@
           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;
           }          
           //
