diff options
author | Shenglei Zhang <shenglei.zhang@intel.com> | 2019-02-25 13:53:37 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2019-03-27 20:11:22 +0800 |
commit | 55756c88aec9d3269d8544746907838ba921e90b (patch) | |
tree | 34bc6d8437f2ea7de3fb87962ee43e65868fa1d9 /BaseTools | |
parent | f67786e381717ee02570d33445ea8c326986b2ac (diff) | |
download | edk2-55756c88aec9d3269d8544746907838ba921e90b.tar.gz |
BaseTools/C/Common: 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/Common/Decompress.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/BaseTools/Source/C/Common/Decompress.c b/BaseTools/Source/C/Common/Decompress.c index 0e9ba0a982..e9ac1d58b3 100644 --- a/BaseTools/Source/C/Common/Decompress.c +++ b/BaseTools/Source/C/Common/Decompress.c @@ -254,10 +254,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;
}
|