From nobody Sat Nov 2 08:29:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1492135241732836.0187019213453; Thu, 13 Apr 2017 19:00:41 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C541E21A04811; Thu, 13 Apr 2017 19:00:39 -0700 (PDT) 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 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 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,195,1488873600"; d="scan'208";a="1155746241" 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: [edk2] [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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Bell Song --- 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 =3D 4; uint32_t upper_bound =3D state->mtf_upper_bound; uint8_t* mtf =3D &state->mtf[4]; /* Make mtf[-1] addressable. */ + uint8_t* mtft =3D &state->mtf[3]; /* Load endian-aware constant. */ const uint8_t b0123[4] =3D {0, 1, 2, 3}; uint32_t pattern; @@ -875,10 +876,10 @@ static BROTLI_NOINLINE void InverseMoveToFrontTransfo= rm( uint8_t value =3D mtf[index]; upper_bound |=3D (uint32_t)v[i]; v[i] =3D value; - mtf[-1] =3D value; - while (index > 0) { + mtft[0] =3D value; + while (index >=3D 0) { + mtft[index + 1] =3D mtft[index]; index--; - mtf[index + 1] =3D mtf[index]; } } /* Remember amount of elements to be reinitialized. */ --=20 2.8.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel