From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BD99F21A04811 for ; Thu, 13 Apr 2017 19:00:37 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2017 19:00:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,195,1488873600"; d="scan'208";a="1155746241" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by fmsmga002.fm.intel.com with ESMTP; 13 Apr 2017 19:00:36 -0700 From: Liming Gao To: edk2-devel@lists.01.org Date: Fri, 14 Apr 2017 09:59:59 +0800 Message-Id: <1492135199-20880-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [PATCH v2] MdeModulePkg BrotliLib: Fix the regression logic issue in loop X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2017 02:00:37 -0000 In V2, change logic to avoid use mtf[-1] style to get value. Roll back to previous logic, and use point + offset to get byte value. Cc: Bell Song Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao --- MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c index 67f0ff2..6557ba6 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c @@ -855,6 +855,7 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransform( uint32_t i = 4; uint32_t upper_bound = state->mtf_upper_bound; uint8_t* mtf = &state->mtf[4]; /* Make mtf[-1] addressable. */ + uint8_t* mtft = &state->mtf[3]; /* Load endian-aware constant. */ const uint8_t b0123[4] = {0, 1, 2, 3}; uint32_t pattern; @@ -875,10 +876,10 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransform( uint8_t value = mtf[index]; upper_bound |= (uint32_t)v[i]; v[i] = value; - mtf[-1] = value; - while (index > 0) { + mtft[0] = value; + while (index >= 0) { + mtft[index + 1] = mtft[index]; index--; - mtf[index + 1] = mtf[index]; } } /* Remember amount of elements to be reinitialized. */ -- 2.8.0.windows.1