]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add the missing check for NULL pointer before use it.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 27 Feb 2010 09:04:11 +0000 (09:04 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 27 Feb 2010 09:04:11 +0000 (09:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10116 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
EdkCompatibilityPkg/Compatibility/FvOnFv2Thunk/FvOnFv2Thunk.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/Ui.h

index faff074209333f7360a868bb269e97a23e5e161d..f5480d2cb6b85d131489735c57312fc7d686bf55 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
 /** @file\r
 Parser for IFR binary encoding.\r
 \r
-Copyright (c) 2008, Intel Corporation\r
+Copyright (c) 2008 - 2010, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -209,6 +209,7 @@ CreateStorage (
   FORMSET_STORAGE  *Storage;\r
 \r
   Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));\r
   FORMSET_STORAGE  *Storage;\r
 \r
   Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));\r
+  ASSERT (Storage != NULL);\r
   Storage->Signature = FORMSET_STORAGE_SIGNATURE;\r
   InsertTailList (&FormSet->StorageListHead, &Storage->Link);\r
 \r
   Storage->Signature = FORMSET_STORAGE_SIGNATURE;\r
   InsertTailList (&FormSet->StorageListHead, &Storage->Link);\r
 \r
@@ -586,6 +587,7 @@ ParseOpCodes (
       // Create a new Form for this FormSet\r
       //\r
       CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM));\r
       // Create a new Form for this FormSet\r
       //\r
       CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM));\r
+      ASSERT (CurrentForm != NULL);\r
       CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE;\r
 \r
       InitializeListHead (&CurrentForm->StatementListHead);\r
       CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE;\r
 \r
       InitializeListHead (&CurrentForm->StatementListHead);\r
@@ -701,6 +703,7 @@ ParseOpCodes (
     //\r
     case EFI_IFR_DEFAULTSTORE_OP:\r
       DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));\r
     //\r
     case EFI_IFR_DEFAULTSTORE_OP:\r
       DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));\r
+      ASSERT (DefaultStore != NULL);\r
       DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;\r
 \r
       CopyMem (&DefaultStore->DefaultId,   &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId,   sizeof (UINT16));\r
       DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;\r
 \r
       CopyMem (&DefaultStore->DefaultId,   &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId,   sizeof (UINT16));\r
@@ -917,6 +920,7 @@ ParseOpCodes (
       // A Question may have more than one Default value which have different default types.\r
       //\r
       CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));\r
       // A Question may have more than one Default value which have different default types.\r
       //\r
       CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));\r
+      ASSERT (CurrentDefault != NULL);\r
       CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;\r
 \r
       CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;\r
       CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;\r
 \r
       CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;\r
@@ -940,6 +944,7 @@ ParseOpCodes (
       // It create a selection for use in current Question.\r
       //\r
       CurrentOption = AllocateZeroPool (sizeof (QUESTION_OPTION));\r
       // It create a selection for use in current Question.\r
       //\r
       CurrentOption = AllocateZeroPool (sizeof (QUESTION_OPTION));\r
+      ASSERT (CurrentOption != NULL);\r
       CurrentOption->Signature = QUESTION_OPTION_SIGNATURE;\r
 \r
       CurrentOption->Flags = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags;\r
       CurrentOption->Signature = QUESTION_OPTION_SIGNATURE;\r
 \r
       CurrentOption->Flags = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags;\r
index ff4165d19ec1c55af78b1ad7c2e3032d63dc3e7a..ef64cc84f16acc8041c9200d503b2a2ebb0237c3 100644 (file)
@@ -7,7 +7,7 @@ these two conditions are true:
 1) Framework module consuming FV is present\r
 2) And the platform only produces FV2\r
 \r
 1) Framework module consuming FV is present\r
 2) And the platform only produces FV2\r
 \r
-Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010 Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -597,6 +597,7 @@ FvWriteFile (
   FirmwareVolume2 = Private->FirmwareVolume2;\r
 \r
   PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);\r
   FirmwareVolume2 = Private->FirmwareVolume2;\r
 \r
   PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);\r
+  ASSERT (PiFileData != NULL);\r
 \r
   //\r
   // Framework Spec assume firmware files are Memory-Mapped.\r
 \r
   //\r
   // Framework Spec assume firmware files are Memory-Mapped.\r
index 2934ab383acf67d6f959209e213df7237df00a94..0339565350c4a951fadeeabdab023898166ff09a 100644 (file)
@@ -3192,7 +3192,7 @@ Exit:
   @param  This                   A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
                                  instance.\r
   @param  ConfigResp             A null-terminated Unicode string in <ConfigResp>\r
   @param  This                   A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
                                  instance.\r
   @param  ConfigResp             A null-terminated Unicode string in <ConfigResp>\r
-                                 format. It can be ConfigAltResp format string.\r
+                                 format.\r
   @param  Block                  A possibly null array of bytes representing the\r
                                  current  block. Only bytes referenced in the\r
                                  ConfigResp string  in the block are modified. If\r
   @param  Block                  A possibly null array of bytes representing the\r
                                  current  block. Only bytes referenced in the\r
                                  ConfigResp string  in the block are modified. If\r
@@ -3415,7 +3415,7 @@ Exit:
   @param  This                   A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
                                  instance.\r
   @param  Configuration          A null-terminated Unicode string in\r
   @param  This                   A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL\r
                                  instance.\r
   @param  Configuration          A null-terminated Unicode string in\r
-                                 <MultiConfigAltResp> format. It is <ConfigAltResp> format.\r
+                                 <MultiConfigAltResp> format.\r
   @param  Guid                   A pointer to the GUID value to search for in the\r
                                  routing portion of the ConfigResp string when\r
                                  retrieving  the requested data. If Guid is NULL,\r
   @param  Guid                   A pointer to the GUID value to search for in the\r
                                  routing portion of the ConfigResp string when\r
                                  retrieving  the requested data. If Guid is NULL,\r
index 90fdc7462ffa17dfab6f7c41ce3615c5c1b0d02c..45ec96edf1bf736bc84eb8fb45975eeeb3eac384 100644 (file)
@@ -1729,6 +1729,7 @@ EvaluateExpression (
             //\r
             Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr);\r
             if (!EFI_ERROR (Status)) {\r
             //\r
             Status = GetValueByName (OpCode->VarStorage, OpCode->ValueName, &StrPtr);\r
             if (!EFI_ERROR (Status)) {\r
+              ASSERT (StrPtr != NULL);\r
               TempLength = StrLen (StrPtr);\r
               if (OpCode->ValueWidth >= ((TempLength + 1) / 2)) {\r
                 Value->Type = OpCode->ValueType;\r
               TempLength = StrLen (StrPtr);\r
               if (OpCode->ValueWidth >= ((TempLength + 1) / 2)) {\r
                 Value->Type = OpCode->ValueType;\r
@@ -1740,7 +1741,7 @@ EvaluateExpression (
                   if ((Index & 1) == 0) {\r
                     TempBuffer [Index/2] = DigitUint8;\r
                   } else {\r
                   if ((Index & 1) == 0) {\r
                     TempBuffer [Index/2] = DigitUint8;\r
                   } else {\r
-                    TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempStr [Index/2]);\r
+                    TempBuffer [Index/2] = (UINT8) ((DigitUint8 << 4) + TempBuffer [Index/2]);\r
                   }\r
                 }\r
               }                \r
                   }\r
                 }\r
               }                \r
index 5593b6eeb5c47649d1766febdee885d6c855cbf6..7660c6ef1fa49f4bc408e480e1b70831bd54fded 100644 (file)
@@ -1174,6 +1174,7 @@ ParseOpCodes (
       //\r
       if (CurrentExpression == NULL && MapScopeDepth > 0) {\r
         CurrentExpression = CreateExpression (CurrentForm);\r
       //\r
       if (CurrentExpression == NULL && MapScopeDepth > 0) {\r
         CurrentExpression = CreateExpression (CurrentForm);\r
+        ASSERT (MapExpressionList != NULL);\r
         InsertTailList (MapExpressionList, &CurrentExpression->Link);\r
         if (Scope == 0) {\r
           SingleOpCodeExpression = TRUE;\r
         InsertTailList (MapExpressionList, &CurrentExpression->Link);\r
         if (Scope == 0) {\r
           SingleOpCodeExpression = TRUE;\r
@@ -2120,6 +2121,7 @@ ParseOpCodes (
         //\r
         Status = PopCurrentExpression ((VOID **) &CurrentExpression);\r
         ASSERT_EFI_ERROR (Status);\r
         //\r
         Status = PopCurrentExpression ((VOID **) &CurrentExpression);\r
         ASSERT_EFI_ERROR (Status);\r
+        ASSERT (MapScopeDepth > 0);\r
         MapScopeDepth --;\r
         break;\r
 \r
         MapScopeDepth --;\r
         break;\r
 \r
index 6d5a3db2e585b76a8fdc58d979c998b8aa211c00..3704596f303a0566e35c6378ba9cc26cd50f5edf 100644 (file)
@@ -109,6 +109,8 @@ NewStrCat (
   hit, then 2 Unicode character will consume an output storage\r
   space with size of CHAR16 till a NARROW_CHAR is hit.\r
 \r
   hit, then 2 Unicode character will consume an output storage\r
   space with size of CHAR16 till a NARROW_CHAR is hit.\r
 \r
+  If String is NULL, then ASSERT ().\r
+\r
   @param String          The input string to be counted.\r
 \r
   @return Storage space for the input string.\r
   @param String          The input string to be counted.\r
 \r
   @return Storage space for the input string.\r
@@ -123,6 +125,11 @@ GetStringWidth (
   UINTN Count;\r
   UINTN IncrementValue;\r
 \r
   UINTN Count;\r
   UINTN IncrementValue;\r
 \r
+  ASSERT (String != NULL);\r
+  if (String == NULL) {\r
+    return 0;\r
+  }\r
+\r
   Index           = 0;\r
   Count           = 0;\r
   IncrementValue  = 1;\r
   Index           = 0;\r
   Count           = 0;\r
   IncrementValue  = 1;\r
index 45fb3eba3efaaced2b38e0e4003c4749a34ed7a3..6b651037149b3ff6ff3479bed8d90d3d09df1234 100644 (file)
@@ -623,6 +623,8 @@ ClearLines (
   hit, then 2 Unicode character will consume an output storage\r
   space with size of CHAR16 till a NARROW_CHAR is hit.\r
 \r
   hit, then 2 Unicode character will consume an output storage\r
   space with size of CHAR16 till a NARROW_CHAR is hit.\r
 \r
+  If String is NULL, then ASSERT ().\r
+\r
   @param String          The input string to be counted.\r
 \r
   @return Storage space for the input string.\r
   @param String          The input string to be counted.\r
 \r
   @return Storage space for the input string.\r