From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B080E20945B6F for ; Thu, 21 Sep 2017 18:53:44 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2017 18:56:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,426,1500966000"; d="scan'208";a="314895316" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 21 Sep 2017 18:56:50 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Hao Wu Date: Fri, 22 Sep 2017 09:56:42 +0800 Message-Id: <1506045402-318760-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] MdeModulePkg/SetupBrowser:Add NULL check before using a pointer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Sep 2017 01:53:44 -0000 Add NULL pointer check before using a pointer to avoid possible NULL pointer dereference. Cc: Eric Dong Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 48beeb6..c2cfa5c 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1484,11 +1484,13 @@ BufferToValue ( // // Other type of Questions // if (Question->QuestionReferToBitField) { Buffer = (UINT8 *)AllocateZeroPool (Question->StorageWidth); - ASSERT (Buffer != NULL); + if (Buffer == NULL) { + return EFI_OUT_OF_RESOURCES; + } Dst = Buffer; } else { Dst = (UINT8 *) &Question->HiiValue.Value; } } @@ -1546,15 +1548,13 @@ BufferToValue ( } } *StringPtr = TempChar; - if (Question->QuestionReferToBitField) { + if (Buffer != NULL && Question->QuestionReferToBitField) { GetBitsQuestionValue (Question, Buffer); - if (Buffer != NULL) { - FreePool (Buffer); - } + FreePool (Buffer); } return Status; } -- 1.9.5.msysgit.1