]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDriver1CommandsLib/DevTree.c
ShellPkg/Dp: Add null pointer check
[mirror_edk2.git] / ShellPkg / Library / UefiShellDriver1CommandsLib / DevTree.c
index 4389ce00cb887c2dbdec58973aec9f02543f6217..6f070eeaa1fd4aec87bf6aaa86f979e58ff28f7c 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Main file for DevTree shell Driver1 function.\r
 \r
-  Copyright (c) 2014 - 2015, Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2010 - 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
@@ -34,7 +34,6 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   @retval SHELL_SUCCESS     The operation was successful.\r
 **/\r
 SHELL_STATUS\r
-EFIAPI\r
 DoDevTreeForHandle(\r
   IN CONST EFI_HANDLE TheHandle,\r
   IN CONST CHAR8      *Lang OPTIONAL,\r
@@ -57,7 +56,8 @@ DoDevTreeForHandle(
   ChildHandleBuffer   = NULL;\r
   ChildCount          = 0;\r
 \r
-  ASSERT(TheHandle    != NULL);\r
+  ASSERT (TheHandle != NULL);\r
+  ASSERT (HiiString != NULL);\r
   \r
   if (ShellGetExecutionBreakFlag()) {\r
     ShellStatus = SHELL_ABORTED;\r
@@ -91,10 +91,10 @@ DoDevTreeForHandle(
     return SHELL_SUCCESS;\r
   }\r
 \r
-  FormatString        = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));\r
-\r
-  ASSERT(HiiString    != NULL);\r
-  ASSERT(FormatString != NULL);\r
+  FormatString = AllocateZeroPool(StrSize(HiiString) + (10)*sizeof(FormatString[0]));\r
+  if (FormatString == NULL) {\r
+    return SHELL_OUT_OF_RESOURCES;\r
+  }\r
 \r
   //\r
   // we generate the format string on the fly so that we can control the\r