Verify memory allocations were successful.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / For.c
index 0e68119..297a137 100644 (file)
@@ -103,8 +103,11 @@ typedef struct {
   @param[in] Alias              The alias to test for.\r
   @param[in] CommandString      The updated command string.\r
   @param[in,out] List           The list to search.\r
+\r
+  @retval EFI_SUCCESS           The operation was completed successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There was not enough free memory.\r
 **/\r
-VOID\r
+EFI_STATUS\r
 EFIAPI\r
 InternalUpdateAliasOnList(\r
   IN CONST CHAR16       *Alias,\r
@@ -139,12 +142,16 @@ InternalUpdateAliasOnList(
   }\r
   if (!Found) {\r
     Node = AllocateZeroPool(sizeof(ALIAS_LIST));\r
+    if (Node == NULL) {\r
+      return (EFI_OUT_OF_RESOURCES);\r
+    }\r
     ASSERT(Node->Alias == NULL);\r
     Node->Alias         = StrnCatGrow(&Node->Alias, NULL, Alias, 0);\r
     ASSERT(Node->CommandString == NULL);\r
     Node->CommandString = StrnCatGrow(&Node->CommandString, NULL, CommandString, 0);\r
     InsertTailList(List, &Node->Link);\r
   }\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 /**\r