From: Eric Dong Date: Mon, 14 Jul 2014 11:01:17 +0000 (+0000) Subject: Add check to make code more safely. X-Git-Tag: edk2-stable201903~11338 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=e77d2f9db2d93896c882edfc1b239e04620503f1 Add check to make code more safely. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15655 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 92474cd282..ff3b7e5b4d 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -2590,6 +2590,7 @@ FindQuestionFromProgress ( // For Name/Value type, Skip the ConfigHdr part. // EndStr = StrStr (Progress, L"PATH="); + ASSERT (EndStr != NULL); while (*EndStr != '&') { EndStr++; } @@ -2600,6 +2601,7 @@ FindQuestionFromProgress ( // For Buffer type, Skip the ConfigHdr part. // EndStr = StrStr (Progress, L"&OFFSET="); + ASSERT (EndStr != NULL); *EndStr = '\0'; } @@ -2615,6 +2617,7 @@ FindQuestionFromProgress ( // here, just keep the "Fred" string. // EndStr = StrStr (Progress, L"="); + ASSERT (EndStr != NULL); *EndStr = '\0'; } else { // @@ -2622,6 +2625,7 @@ FindQuestionFromProgress ( // here, just keep the "OFFSET=0x####&WIDTH=0x####" string. // EndStr = StrStr (Progress, L"&VALUE="); + ASSERT (EndStr != NULL); *EndStr = '\0'; } @@ -4246,9 +4250,8 @@ IsQuestionValueChanged ( } CopyMem (&Question->HiiValue, &BackUpValue, sizeof (EFI_HII_VALUE)); - CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth); - if (BackUpBuffer != NULL) { + CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth); FreePool (BackUpBuffer); }