]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Do NULL pointer check before the pointer is used.
authorQiu Shumin <shumin.qiu@intel.com>
Tue, 16 Feb 2016 01:49:05 +0000 (09:49 +0800)
committerQiu Shumin <shumin.qiu@intel.com>
Thu, 18 Feb 2016 06:00:57 +0000 (14:00 +0800)
The pointer 'FileInterface->Buffer' returned from 'AllocateZeroPool' in function
'CreateFileInterfaceMem' may be NULL and will be dereferenced at the following code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Application/Shell/FileHandleWrappers.c

index 168b78bd25fa9b77537c6130ad952998c13dcece..f8306e214704edf6fbd57adaa6db2f84d27ca88d 100644 (file)
@@ -3,7 +3,7 @@
   StdIn, StdOut, StdErr, etc...).\r
 \r
   Copyright 2016 Dell Inc.\r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1516,6 +1516,10 @@ CreateFileInterfaceMem(
 \r
   if (Unicode) {\r
     FileInterface->Buffer = AllocateZeroPool(sizeof(gUnicodeFileTag));\r
+    if (FileInterface->Buffer == NULL) {\r
+      FreePool (FileInterface);\r
+      return NULL;\r
+    }\r
     *((CHAR16 *) (FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;\r
     FileInterface->BufferSize = 2;\r
     FileInterface->Position = 2;\r