summaryrefslogtreecommitdiffstats
path: root/BaseTools
diff options
context:
space:
mode:
authorShenglei Zhang <shenglei.zhang@intel.com>2019-02-25 13:37:56 +0800
committerLiming Gao <liming.gao@intel.com>2019-03-27 20:11:22 +0800
commitf67786e381717ee02570d33445ea8c326986b2ac (patch)
treeb8ab465fb348d602cce5a1334c149c8acab13051 /BaseTools
parenta068102296180b7e2481467080c84e02e89de980 (diff)
downloadedk2-f67786e381717ee02570d33445ea8c326986b2ac.tar.gz
edk2-f67786e381717ee02570d33445ea8c326986b2ac.tar.bz2
edk2-f67786e381717ee02570d33445ea8c326986b2ac.zip
BaseTools/TianoCompress: Improve performance of boundary validation
The boundary validation checking in MakeTable() performs on every loop iteration. This could be improved by checking just once before the loop. https://bugzilla.tianocore.org/show_bug.cgi?id=1329 Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/TianoCompress/TianoCompress.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c
index 29b11c597f..ae88074360 100644
--- a/BaseTools/Source/C/TianoCompress/TianoCompress.c
+++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c
@@ -2281,10 +2281,11 @@ Returns:
if (Len <= TableBits) {
+ if (Start[Len] >= NextCode || NextCode > MaxTableLength){
+ return (UINT16) BAD_TABLE;
+ }
+
for (Index = Start[Len]; Index < NextCode; Index++) {
- if (Index >= MaxTableLength) {
- return (UINT16) BAD_TABLE;
- }
Table[Index] = Char;
}