]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/ParseGuidedSectionTools.c
BaseTools/C/Common: Avoid possible NULL pointer dereference
[mirror_edk2.git] / BaseTools / Source / C / Common / ParseGuidedSectionTools.c
index e3f0ccb597df6e106c287f53b1fa5292ee2cf391..fc8f488f7e46e646c30a62b6e9a305bcc7c90077 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Helper functions for parsing GuidedSectionTools.txt\r
 \r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -144,13 +144,14 @@ Returns:
           NewGuidTool->Name = CloneString(Tool->Strings[1]);\r
           NewGuidTool->Path = CloneString(Tool->Strings[2]);\r
           NewGuidTool->Next = NULL;\r
+\r
+          if (FirstGuidTool == NULL) {\r
+            FirstGuidTool = NewGuidTool;\r
+          } else {\r
+            LastGuidTool->Next = NewGuidTool;\r
+          }\r
+          LastGuidTool = NewGuidTool;\r
         }\r
-        if (FirstGuidTool == NULL) {\r
-          FirstGuidTool = NewGuidTool;\r
-        } else {\r
-          LastGuidTool->Next = NewGuidTool;\r
-        }\r
-        LastGuidTool = NewGuidTool;\r
       }\r
       FreeStringList (Tool);\r
     }\r