From 21902410ad87aadd3a68ec7ecb4ee11594d9fcb0 Mon Sep 17 00:00:00 2001 From: Bret Barkelew Date: Wed, 12 Jun 2019 14:04:57 +0800 Subject: ShellPkg/UefiShellLib: Set input pointer parameter to null if failure 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 Cc: Ray Ni Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Signed-off-by: Zhichao Gao Reviewed-by: Ray Ni --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 430b20e127..5be530092e 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -3366,6 +3366,9 @@ ShellPromptForResponse ( if (Type != ShellPromptResponseTypeFreeform) { Resp = (SHELL_PROMPT_RESPONSE*)AllocateZeroPool(sizeof(SHELL_PROMPT_RESPONSE)); if (Resp == NULL) { + if (Response != NULL) { + *Response = NULL; + } return (EFI_OUT_OF_RESOURCES); } } @@ -3568,6 +3571,8 @@ ShellPromptForResponse ( *Response = Resp; } else if (Buffer != NULL) { *Response = Buffer; + } else { + *Response = NULL; } } else { if (Resp != NULL) { -- cgit v1.2.3