Current code only as bounds checks in ASSERT macros.
They are also needed in release mode where ASSERT is not used.

Signed-off-by: Nate DeSimone <[email protected]>
Cc: Chasel Chiu <[email protected]>
Cc: Nate DeSimone <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
---
 .../MinPlatformPkg/Library/CompressLib/CompressLib.c   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c 
b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
index 9f93e1ee2d..537eb3b693 100644
--- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c
@@ -1002,7 +1002,10 @@ CountTFreq (
         mTFreq[2]++;
       }
     } else {
-      ASSERT((LoopVar3+2)<(2 * NT - 1));
+      ASSERT ((LoopVar3 + 2) < (2 * NT - 1));
+      if ((LoopVar3 + 2) >= (2 * NT - 1)) {
+        return;
+      }
       mTFreq[LoopVar3 + 2]++;
     }
   }
@@ -1101,7 +1104,10 @@ WriteCLen (
         PutBits (CBIT, Count - 20);
       }
     } else {
-      ASSERT((LoopVar3+2)<NPT);
+      ASSERT ((LoopVar3 + 2) < NPT);
+      if ((LoopVar3 + 2) >= NPT) {
+        return;
+      }
       PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]);
     }
   }
-- 
2.27.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#65737): https://edk2.groups.io/g/devel/message/65737
Mute This Topic: https://groups.io/mt/77208968/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to