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>
This commit is contained in:
Dandan Bi 2017-09-22 09:28:28 +08:00 committed by Hao Wu
parent 96207191fd
commit 66918edd34
1 changed files with 5 additions and 5 deletions

View File

@ -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;