From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web11.565.1572588865857342767 for ; Thu, 31 Oct 2019 23:14:31 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 23:14:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,254,1569308400"; d="scan'208";a="204426586" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 31 Oct 2019 23:14:30 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu Subject: [PATCH v3 4/4] MdeModulePkg/SetupBrowserDxe: ASSERT GetBufferForValue(&Value) Date: Fri, 1 Nov 2019 14:14:17 +0800 Message-Id: <20191101061417.28896-5-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20191101061417.28896-1-shenglei.zhang@intel.com> References: <20191101061417.28896-1-shenglei.zhang@intel.com> Before called by GetBufferForValue(), Value has already been called function IsTypeInBuffer to make sure the value must be buffer type. So GetBufferForValue can not return NULL. This commit adds ASSERT to assume (GetBufferForValue (&Value) is not NULL. Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Shenglei Zhang --- v3: Add ASSERT instead of using error handling. MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c index 7f4929c2fcd9..138912e00823 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -1281,7 +1281,10 @@ IfrToUint ( Result->Type = EFI_IFR_TYPE_UNDEFINED; return EFI_SUCCESS; } + + ASSERT ((GetBufferForValue (&Value) != NULL); Result->Value.u64 = *(UINT64*) GetBufferForValue (&Value); + if (Value.Type == EFI_IFR_TYPE_BUFFER) { FreePool (Value.Buffer); } -- 2.18.0.windows.1