From: Shenglei Zhang Date: Mon, 25 Feb 2019 05:37:56 +0000 (+0800) Subject: BaseTools/TianoCompress: Improve performance of boundary validation X-Git-Tag: edk2-stable201905~419 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=f67786e381717ee02570d33445ea8c326986b2ac 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 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Shenglei Zhang Reviewed-by: Liming Gao --- 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; }