From 1cd45e787dc658e17a92292795b93ce71d01be4b Mon Sep 17 00:00:00 2001 From: jcarsey Date: Fri, 29 Jan 2010 15:07:44 +0000 Subject: fix K8 coding issues. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9862 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'ShellPkg/Library/UefiShellLib') diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index f105176bf6..0d6a30e6e9 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -107,7 +107,7 @@ ShellFindSE2 ( Buffer ); } - if (!EFI_ERROR (Status)) { + if (!EFI_ERROR (Status) && Buffer != NULL) { // // now parse the list of returned handles // @@ -1490,6 +1490,7 @@ ShellFindFilePath ( CHAR16 *TestPath; CONST CHAR16 *Walker; UINTN Size; + CHAR16 *TempChar; RetVal = NULL; @@ -1517,8 +1518,9 @@ ShellFindFilePath ( Walker = (CHAR16*)Path; do { CopyMem(TestPath, Walker, StrSize(Walker)); - if (StrStr(TestPath, L";") != NULL) { - *(StrStr(TestPath, L";")) = CHAR_NULL; + TempChar = StrStr(TestPath, L";"); + if (TempChar != NULL) { + *TempChar = CHAR_NULL; } StrCat(TestPath, FileName); if (StrStr(Walker, L";") != NULL) { @@ -1565,6 +1567,8 @@ ShellFindFilePathEx ( CHAR16 *RetVal; CONST CHAR16 *ExtensionWalker; UINTN Size; + CHAR16 *TempChar; + ASSERT(FileName != NULL); if (FileExtension == NULL) { return (ShellFindFilePath(FileName)); @@ -1578,9 +1582,12 @@ ShellFindFilePathEx ( TestPath = AllocateZeroPool(Size); for (ExtensionWalker = FileExtension ; ; ExtensionWalker = StrStr(ExtensionWalker, L";") + 1 ){ StrCpy(TestPath, FileName); - StrCat(TestPath, ExtensionWalker); - if (StrStr(TestPath, L";") != NULL) { - *(StrStr(TestPath, L";")) = CHAR_NULL; + if (ExtensionWalker != NULL) { + StrCat(TestPath, ExtensionWalker); + } + TempChar = StrStr(TestPath, L";"); + if (TempChar != NULL) { + *TempChar = CHAR_NULL; } RetVal = ShellFindFilePath(TestPath); if (RetVal != NULL) { @@ -2696,10 +2703,15 @@ ShellStrToUintn( { CONST CHAR16 *Walker; for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker++); - if (StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){ - return (StrHexToUintn(Walker)); + if (Walker == NULL || *Walker == CHAR_NULL) { + ASSERT(FALSE); + return ((UINTN)(-1)); + } else { + if (StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){ + return (StrHexToUintn(Walker)); + } + return (StrDecimalToUintn(Walker)); } - return (StrDecimalToUintn(Walker)); } /** -- cgit v1.2.3