diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-12 13:42:59 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2016-07-18 10:55:08 +0800 |
commit | d758f80971a7447328d67dd5d4dd2a94dabe1656 (patch) | |
tree | bebac0f174f8a8add71fcd302c99f3709c7587e8 /ShellPkg/Library | |
parent | 9168df3dea65f707d1e9c32eba5e18ef6b84e5cd (diff) | |
download | edk2-d758f80971a7447328d67dd5d4dd2a94dabe1656.tar.gz edk2-d758f80971a7447328d67dd5d4dd2a94dabe1656.tar.bz2 edk2-d758f80971a7447328d67dd5d4dd2a94dabe1656.zip |
ShellPkg/Dp: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/UefiDpLib/Dp.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiDpLib/Dp.c b/ShellPkg/Library/UefiDpLib/Dp.c index 4bad3c2f72..75c7d11dc3 100644 --- a/ShellPkg/Library/UefiDpLib/Dp.c +++ b/ShellPkg/Library/UefiDpLib/Dp.c @@ -259,13 +259,19 @@ ShellCommandRunDp ( CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
if (CustomCumulativeToken != NULL) {
CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
- ASSERT (CustomCumulativeData != NULL);
+ if (CustomCumulativeData == NULL) {
+ return SHELL_OUT_OF_RESOURCES;
+ }
CustomCumulativeData->MinDur = 0;
CustomCumulativeData->MaxDur = 0;
CustomCumulativeData->Count = 0;
CustomCumulativeData->Duration = 0;
NameSize = StrLen (CustomCumulativeToken) + 1;
CustomCumulativeData->Name = AllocateZeroPool (NameSize);
+ if (CustomCumulativeData->Name == NULL) {
+ FreePool (CustomCumulativeData);
+ return SHELL_OUT_OF_RESOURCES;
+ }
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
}
|