summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-10 20:32:17 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-10-10 20:32:17 +0000
commitecae51177e83db0d99f8b4888ae4b866c18651b6 (patch)
tree61522e5d6294adbafeb58f35e61b090358c5126d /ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
parentbeab0fc5e2ea7c676968991b1ae8e1fc72aef19f (diff)
downloadedk2-ecae51177e83db0d99f8b4888ae4b866c18651b6.tar.gz
edk2-ecae51177e83db0d99f8b4888ae4b866c18651b6.tar.bz2
edk2-ecae51177e83db0d99f8b4888ae4b866c18651b6.zip
ShellPkg: Add checks for NULL pointers.
This adds lots of pointer verification with ASSERTs only used when the condition should be impossible and never for memory allocation. signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12523 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c')
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
index 06a3210ea0..b1f8327f4a 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
@@ -607,8 +607,10 @@ FreadCrc (
Advance the current position (read in new data if needed).
Delete outdated string info. Find a match string for current position.
+ @retval TRUE The operation was successful.
+ @retval FALSE The operation failed due to insufficient memory.
**/
-VOID
+BOOLEAN
EFIAPI
GetNextMatch (
VOID
@@ -621,6 +623,9 @@ GetNextMatch (
mPos++;
if (mPos == WNDSIZ * 2) {
Temp = AllocateZeroPool (WNDSIZ + MAXMATCH);
+ if (Temp == NULL) {
+ return (FALSE);
+ }
CopyMem (Temp, &mText[WNDSIZ], WNDSIZ + MAXMATCH);
CopyMem (&mText[0], Temp, WNDSIZ + MAXMATCH);
FreePool (Temp);
@@ -631,6 +636,8 @@ GetNextMatch (
DeleteNode ();
InsertNode ();
+
+ return (TRUE);
}
/**
@@ -1286,7 +1293,9 @@ Encode (
while (mRemainder > 0) {
LastMatchLen = mMatchLen;
LastMatchPos = mMatchPos;
- GetNextMatch ();
+ if (!GetNextMatch ()) {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
if (mMatchLen > mRemainder) {
mMatchLen = mRemainder;
}
@@ -1306,7 +1315,9 @@ Encode (
(mPos - LastMatchPos - 2) & (WNDSIZ - 1));
LastMatchLen--;
while (LastMatchLen > 0) {
- GetNextMatch ();
+ if (!GetNextMatch ()) {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
LastMatchLen--;
}
@@ -1318,7 +1329,7 @@ Encode (
HufEncodeEnd ();
FreeMemory ();
- return EFI_SUCCESS;
+ return (Status);
}
/**