diff options
author | Qiu Shumin <shumin.qiu@intel.com> | 2016-02-16 09:49:05 +0800 |
---|---|---|
committer | Qiu Shumin <shumin.qiu@intel.com> | 2016-02-18 14:00:57 +0800 |
commit | 9eec4d38c027e9eb95c545875a1f847f0cb3dcbf (patch) | |
tree | 0f7150bb19a0b00f1490101127b8efb57cba5d04 /ShellPkg | |
parent | 3700da73846e10853ed95010d7ad2f0b9135439f (diff) | |
download | edk2-platforms-9eec4d38c027e9eb95c545875a1f847f0cb3dcbf.tar.xz |
ShellPkg: Do NULL pointer check before the pointer is used.
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>
Diffstat (limited to 'ShellPkg')
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleWrappers.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index 168b78bd25..f8306e2147 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -3,7 +3,7 @@ StdIn, StdOut, StdErr, etc...).
Copyright 2016 Dell Inc.
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1516,6 +1516,10 @@ CreateFileInterfaceMem( if (Unicode) {
FileInterface->Buffer = AllocateZeroPool(sizeof(gUnicodeFileTag));
+ if (FileInterface->Buffer == NULL) {
+ FreePool (FileInterface);
+ return NULL;
+ }
*((CHAR16 *) (FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;
FileInterface->BufferSize = 2;
FileInterface->Position = 2;
|