]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenPage/GenPage.c
BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions
[mirror_edk2.git] / BaseTools / Source / C / GenPage / GenPage.c
index ef69823fdad27364aaa7a90a3e3839acb9f020ea..3bb05efa36cd06b86c31f4b6eb08ee8144d83058 100644 (file)
@@ -15,7 +15,7 @@
                           Directory-Ptr Directory {512}\r
                         ) {4}\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -146,6 +146,10 @@ Return:
   X64_PAGE_TABLE_ENTRY_2M                       *PageDirectoryEntry2MB;\r
 \r
   PageTable = (void *)malloc (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE);\r
+  if (PageTable == NULL) {\r
+    Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+    return NULL;\r
+  }\r
   memset (PageTable, 0, (EFI_PAGE_NUMBER * EFI_SIZE_OF_PAGE));\r
   PageTablePtr = PageTable;\r
 \r
@@ -417,15 +421,21 @@ main (
   // Create X64 page table\r
   //\r
   BaseMemory = CreateIdentityMappingPageTables ();\r
+  if (BaseMemory == NULL) {\r
+    Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+    return STATUS_ERROR;\r
+  }\r
 \r
   //\r
   // Add page table to binary file\r
   //\r
   result = GenBinPage (BaseMemory, InputFile, OutputFile);\r
   if (result < 0) {\r
+    free (BaseMemory);\r
     return STATUS_ERROR;\r
   }\r
 \r
+  free (BaseMemory);\r
   return 0;\r
 }\r
 \r