diff options
author | Dandan Bi <dandan.bi@intel.com> | 2017-09-22 09:28:28 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-09-22 14:58:41 +0800 |
commit | 66918edd34fd2b6edb5f3f7b86bdd40e833d40ff (patch) | |
tree | 589e15b7edac5305b7ac20d76a954ad0004bc54b | |
parent | 96207191fd715e268c6ba6d6ac8650ef914e1686 (diff) | |
download | edk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.zip edk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.tar.gz edk2-66918edd34fd2b6edb5f3f7b86bdd40e833d40ff.tar.bz2 |
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>
-rw-r--r-- | MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 10 |
1 files 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 @@ -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;
|