summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Application/Shell/ShellProtocol.c
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-04 16:24:30 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-04 16:24:30 +0000
commit3c865f2064d37eaccd1693b878596d5138b0b38e (patch)
treeffe10112e71c18c5c4ec56f37cc670258b22fd5b /ShellPkg/Application/Shell/ShellProtocol.c
parentaca84419c4b5128b69215b8f6e4d34c36efb1fbc (diff)
downloadedk2-3c865f2064d37eaccd1693b878596d5138b0b38e.tar.gz
edk2-3c865f2064d37eaccd1693b878596d5138b0b38e.tar.bz2
edk2-3c865f2064d37eaccd1693b878596d5138b0b38e.zip
1) Removing ASSERTs for proper return values.
2) Verifying that memory allocations were successful. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10904 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Application/Shell/ShellProtocol.c')
-rw-r--r--ShellPkg/Application/Shell/ShellProtocol.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 27488ab62e..eaec87971d 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -666,6 +666,9 @@ EfiShellGetDeviceName(
}
if (Language == NULL) {
Lang = AllocatePool(AsciiStrSize(CompName2->SupportedLanguages));
+ if (Lang == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
AsciiStrCpy(Lang, CompName2->SupportedLanguages);
TempChar = AsciiStrStr(Lang, ";");
if (TempChar != NULL){
@@ -673,6 +676,9 @@ EfiShellGetDeviceName(
}
} else {
Lang = AllocatePool(AsciiStrSize(Language));
+ if (Lang == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
AsciiStrCpy(Lang, Language);
}
Status = CompName2->GetControllerName(CompName2, DeviceHandle, NULL, Lang, &DeviceNameToReturn);
@@ -686,7 +692,7 @@ EfiShellGetDeviceName(
FreePool(HandleList);
}
if (DeviceNameToReturn != NULL){
- ASSERT(BestDeviceName == NULL);
+ ASSERT(BestDeviceName != NULL);
StrnCatGrow(BestDeviceName, NULL, DeviceNameToReturn, 0);
return (EFI_SUCCESS);
}
@@ -2270,6 +2276,12 @@ EfiShellGetEnv(
Size += 2*sizeof(CHAR16);
Buffer = AllocateZeroPool(Size);
+ if (Buffer == NULL) {
+ if (!IsListEmpty (&List)) {
+ FreeEnvironmentVariableList(&List);
+ }
+ return (NULL);
+ }
CurrentWriteLocation = (CHAR16*)Buffer;
for ( Node = (ENV_VAR_LIST*)GetFirstNode(&List)
@@ -2284,7 +2296,9 @@ EfiShellGetEnv(
//
// Free the list...
//
- FreeEnvironmentVariableList(&List);
+ if (!IsListEmpty (&List)) {
+ FreeEnvironmentVariableList(&List);
+ }
} else {
//
// We are doing a specific environment variable
@@ -2506,7 +2520,7 @@ EfiShellSetCurDir(
TempString = NULL;
DirectoryName = NULL;
- if (FileSystem == NULL && Dir == NULL) {
+ if ((FileSystem == NULL && Dir == NULL) || Dir == NULL) {
return (EFI_INVALID_PARAMETER);
}
@@ -2733,6 +2747,10 @@ InternalEfiShellGetListAlias(
RetSize = 0;
RetVal = NULL;
+ if (VariableName == NULL) {
+ return (NULL);
+ }
+
VariableName[0] = CHAR_NULL;
while (TRUE) {