summaryrefslogtreecommitdiff
path: root/ShellPkg/Application/Shell/ShellEnvVar.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/ShellEnvVar.c
parentaca84419c4b5128b69215b8f6e4d34c36efb1fbc (diff)
downloadedk2-platforms-3c865f2064d37eaccd1693b878596d5138b0b38e.tar.xz
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/ShellEnvVar.c')
-rw-r--r--ShellPkg/Application/Shell/ShellEnvVar.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/ShellPkg/Application/Shell/ShellEnvVar.c b/ShellPkg/Application/Shell/ShellEnvVar.c
index ff353c4e2a..cd55fa907b 100644
--- a/ShellPkg/Application/Shell/ShellEnvVar.c
+++ b/ShellPkg/Application/Shell/ShellEnvVar.c
@@ -144,27 +144,30 @@ GetEnvironmentVariableList(
UINTN ValSize;
ENV_VAR_LIST *VarList;
- ASSERT(ListHead != NULL);
+ if (ListHead == NULL) {
+ return (EFI_INVALID_PARAMETER);
+ }
Status = gRT->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, &MaxStorSize, &RemStorSize, &MaxVarSize);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) {
+ return (Status);
+ }
NameSize = (UINTN)MaxVarSize;
VariableName = AllocatePool(NameSize);
+ if (VariableName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
StrCpy(VariableName, L"");
- while (TRUE) {
+ while (!EFI_ERROR(Status)) {
NameSize = (UINTN)MaxVarSize;
Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
if (Status == EFI_NOT_FOUND){
Status = EFI_SUCCESS;
break;
}
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) {
- break;
- }
- if (CompareGuid(&Guid, &gShellVariableGuid)){
+ if (!EFI_ERROR(Status) && CompareGuid(&Guid, &gShellVariableGuid)){
VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
ValSize = 0;
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
@@ -173,12 +176,12 @@ GetEnvironmentVariableList(
ASSERT(VarList->Val != NULL);
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
}
- ASSERT_EFI_ERROR(Status);
- VarList->Key = AllocatePool(StrSize(VariableName));
- ASSERT(VarList->Key != NULL);
- StrCpy(VarList->Key, VariableName);
-
- InsertTailList(ListHead, &VarList->Link);
+ if (!EFI_ERROR(Status)) {
+ VarList->Key = AllocatePool(StrSize(VariableName));
+ ASSERT(VarList->Key != NULL);
+ StrCpy(VarList->Key, VariableName);
+ InsertTailList(ListHead, &VarList->Link);
+ }
} // compare guid
} // while
FreePool(VariableName);