summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/SetupBrowserDxe
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2017-09-22 09:28:28 +0800
committerHao Wu <hao.a.wu@intel.com>2017-09-22 14:58:41 +0800
commit66918edd34fd2b6edb5f3f7b86bdd40e833d40ff (patch)
tree589e15b7edac5305b7ac20d76a954ad0004bc54b /MdeModulePkg/Universal/SetupBrowserDxe
parent96207191fd715e268c6ba6d6ac8650ef914e1686 (diff)
downloadedk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.tar.gz
edk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.tar.bz2
edk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.zip
MdeModulePkg/SetupBrowser:Add NULL check before using a pointer
Add NULL pointer check before using a pointer to avoid possible NULL pointer dereference. Cc: Eric Dong <eric.dong@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/SetupBrowserDxe')
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Setup.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 48beeb6539..c2cfa5c5c8 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1486,7 +1486,9 @@ BufferToValue (
//
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;
@@ -1548,11 +1550,9 @@ BufferToValue (
*StringPtr = TempChar;
- if (Question->QuestionReferToBitField) {
+ if (Buffer != NULL && Question->QuestionReferToBitField) {
GetBitsQuestionValue (Question, Buffer);
- if (Buffer != NULL) {
- FreePool (Buffer);
- }
+ FreePool (Buffer);
}
return Status;