Reviewed-by: Hao Wu <hao.a...@intel.com>
Best Regards, Hao Wu > -----Original Message----- > From: Bi, Dandan > Sent: Friday, September 22, 2017 9:57 AM > To: edk2-devel@lists.01.org > Cc: Dong, Eric; Wu, Hao A > Subject: [patch] 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.d...@intel.com> > Cc: Hao Wu <hao.a...@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi <dandan...@intel.com> > --- > 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel