X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FBrotliCustomDecompressLib%2Fdec%2Fdecode.c;h=3bee3e71fe0340c6680b30597d86a89c98ed04d1;hp=67f0ff2cd96fbdb86fcb6ed3dc78b32775c10ae9;hb=792ace0ac391c37c1299322340abdf74e2603795;hpb=36a0d5cab8c9a6ad628ca8e6ccb5d63ed87a53dd diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c index 67f0ff2cd9..3bee3e71fe 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/dec/decode.c @@ -56,7 +56,7 @@ BrotliDecoderState* BrotliDecoderCreateInstance( brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) { BrotliDecoderState* state = 0; if (!alloc_func && !free_func) { - state = (BrotliDecoderState*)malloc(sizeof(BrotliDecoderState)); + state = (BrotliDecoderState*)BrDummyMalloc(sizeof(BrotliDecoderState)); } else if (alloc_func && free_func) { state = (BrotliDecoderState*)alloc_func(opaque, sizeof(BrotliDecoderState)); } @@ -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. */