]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add check to make code more safely.
authorEric Dong <eric.dong@intel.com>
Mon, 14 Jul 2014 11:01:17 +0000 (11:01 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Jul 2014 11:01:17 +0000 (11:01 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15655 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Setup.c

index 92474cd282da8992c5c71f6048af0d3a1198c952..ff3b7e5b4d9621c473552845a8c2118c439145ef 100644 (file)
@@ -2590,6 +2590,7 @@ FindQuestionFromProgress (
       // For Name/Value type, Skip the ConfigHdr part.\r
       //\r
       EndStr = StrStr (Progress, L"PATH=");\r
+      ASSERT (EndStr != NULL);\r
       while (*EndStr != '&') {\r
         EndStr++;\r
       }\r
@@ -2600,6 +2601,7 @@ FindQuestionFromProgress (
       // For Buffer type, Skip the ConfigHdr part.\r
       //\r
       EndStr = StrStr (Progress, L"&OFFSET=");\r
+      ASSERT (EndStr != NULL);\r
       *EndStr = '\0';\r
     }\r
 \r
@@ -2615,6 +2617,7 @@ FindQuestionFromProgress (
     // here, just keep the "Fred" string.\r
     //\r
     EndStr = StrStr (Progress, L"=");\r
+    ASSERT (EndStr != NULL);\r
     *EndStr = '\0';\r
   } else {\r
     //\r
@@ -2622,6 +2625,7 @@ FindQuestionFromProgress (
     // here, just keep the "OFFSET=0x####&WIDTH=0x####" string.\r
     //\r
     EndStr = StrStr (Progress, L"&VALUE=");\r
+    ASSERT (EndStr != NULL);\r
     *EndStr = '\0';\r
   }\r
 \r
@@ -4246,9 +4250,8 @@ IsQuestionValueChanged (
   }\r
 \r
   CopyMem (&Question->HiiValue, &BackUpValue, sizeof (EFI_HII_VALUE));\r
-  CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth);\r
-\r
   if (BackUpBuffer != NULL) {\r
+    CopyMem (Question->BufferValue, BackUpBuffer, BufferWidth);\r
     FreePool (BackUpBuffer);\r
   }\r
 \r