From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 51C1B21A04811 for ; Thu, 13 Apr 2017 03:36:09 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2017 03:36:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,194,1488873600"; d="scan'208";a="1155316106" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by fmsmga002.fm.intel.com with ESMTP; 13 Apr 2017 03:36:08 -0700 From: Liming Gao To: edk2-devel@lists.01.org Date: Thu, 13 Apr 2017 18:36:05 +0800 Message-Id: <1492079765-15740-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] 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: Thu, 13 Apr 2017 10:36:09 -0000 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c index 67f0ff2..420d1bb 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c @@ -872,14 +872,14 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransform( upper_bound = 0; for (i = 0; i < v_len; ++i) { int index = v[i]; - uint8_t value = mtf[index]; + uint8_t value = *(mtf + index); upper_bound |= (uint32_t)v[i]; v[i] = value; - mtf[-1] = value; - while (index > 0) { + *(mtf - 1) = value; + do { index--; - mtf[index + 1] = mtf[index]; - } + *(mtf + index + 1) = *(mtf + index); + } while (index >= 0); } /* Remember amount of elements to be reinitialized. */ state->mtf_upper_bound = upper_bound; -- 2.8.0.windows.1