]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Correct a bug that allocate a fix size buffer as input buffer for Hii->GetString...
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 6 Aug 2007 09:42:56 +0000 (09:42 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 6 Aug 2007 09:42:56 +0000 (09:42 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3555 6f19259b-4bc3-4df7-8a09-765794883524

Nt32Pkg/PlatformBdsDxe/Generic/FrontPage.c

index 93b27c5ed42574c533ac9844fd8cb2c2ce167b4e..6df4d86426cce5ff24db0a80cfce5646eebe440b 100644 (file)
@@ -332,17 +332,6 @@ ReInitStrings:
 \r
   OptionCount = 0;\r
 \r
-  //\r
-  // Try for a 512 byte Buffer\r
-  //\r
-  BufferSize = 0x200;\r
-\r
-  //\r
-  // Allocate memory for our Form binary\r
-  //\r
-  StringBuffer = AllocateZeroPool (BufferSize);\r
-  ASSERT (StringBuffer != NULL);\r
-\r
   for (Index = 0; LanguageString[Index] != 0; Index += 3) {\r
     Token = 0;\r
     CopyMem (Lang, &LanguageString[Index], 6);\r
@@ -352,8 +341,14 @@ ReInitStrings:
       mLastSelection = (UINT16) OptionCount;\r
     }\r
 \r
+    BufferSize = 0;\r
+    Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, NULL);\r
+    ASSERT(Status == EFI_BUFFER_TOO_SMALL);\r
+    StringBuffer = AllocateZeroPool (BufferSize);\r
+    ASSERT (StringBuffer != NULL);\r
     Status = gHii->GetString (gHii, gStringPackHandle, 1, TRUE, Lang, &BufferSize, StringBuffer);\r
     gHii->NewString (gHii, NULL, gStringPackHandle, &Token, StringBuffer);\r
+    FreePool (StringBuffer);\r
     CopyMem (&OptionList[OptionCount].StringToken, &Token, sizeof (UINT16));\r
     CopyMem (&OptionList[OptionCount].Value, &OptionCount, sizeof (UINT16));\r
     Key = 0x1234;\r
@@ -365,7 +360,6 @@ ReInitStrings:
   FreePool (LanguageString);\r
 \r
   if (ReInitializeStrings) {\r
-    FreePool (StringBuffer);\r
     FreePool (OptionList);\r
     return EFI_SUCCESS;\r
   }\r
@@ -391,7 +385,6 @@ ReInitStrings:
   //\r
   // FreePool (OptionList);\r
   //\r
-  FreePool (StringBuffer);\r
   return Status;\r
 }\r
 \r