]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiShellLib: Set input pointer parameter to null if failure
authorBret Barkelew <Bret.Barkelew@microsoft.com>
Wed, 12 Jun 2019 06:04:57 +0000 (14:04 +0800)
committerJaben Carsey <jaben.carsey@intel.com>
Mon, 1 Jul 2019 16:47:16 +0000 (09:47 -0700)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1906

While failed to allocate memory to save the response,
set the input/output parameter 'Response'(VOID **) to
NULL to indicate the failure not only depend on the
returned status.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 430b20e1272d968b70bde58ebb2c16fc878cd104..5be530092e1ba14985773319af6275d73346e93c 100644 (file)
@@ -3366,6 +3366,9 @@ ShellPromptForResponse (
   if (Type != ShellPromptResponseTypeFreeform) {\r
     Resp = (SHELL_PROMPT_RESPONSE*)AllocateZeroPool(sizeof(SHELL_PROMPT_RESPONSE));\r
     if (Resp == NULL) {\r
+      if (Response != NULL) {\r
+        *Response = NULL;\r
+      }\r
       return (EFI_OUT_OF_RESOURCES);\r
     }\r
   }\r
@@ -3568,6 +3571,8 @@ ShellPromptForResponse (
       *Response = Resp;\r
     } else if (Buffer != NULL) {\r
       *Response = Buffer;\r
+    } else {\r
+      *Response = NULL;\r
     }\r
   } else {\r
     if (Resp != NULL) {\r