From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: zhichao.gao@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Tue, 11 Jun 2019 23:14:13 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jun 2019 23:14:12 -0700 X-ExtLoop1: 1 Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 11 Jun 2019 23:14:11 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Bret Barkelew , Jaben Carsey , Ray Ni , Liming Gao , Sean Brogan , Michael Turner Subject: [PATCH] ShellPkg/UefiShellLib: Set input pointer parameter to null if failure Date: Wed, 12 Jun 2019 14:13:57 +0800 Message-Id: <20190612061357.15352-1-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Bret Barkelew 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 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 5 +++++ 1 file changed, 5 insertions(+) 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) { -- 2.21.0.windows.1