From 9b8b9bf2ea25e9dc706287af6458e6fef0f50e16 Mon Sep 17 00:00:00 2001 From: Daniel Lobl Date: Wed, 2 Sep 2026 17:22:39 +0200 Subject: [PATCH] fix: cast to uint64_t before LZW buffer length calc --- src/cgif_raw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cgif_raw.c b/src/cgif_raw.c index 56f9533..832a9d9 100644 --- a/src/cgif_raw.c +++ b/src/cgif_raw.c @@ -349,8 +349,8 @@ static int LZW_GenerateStream(LZWResult* pResult, const uint32_t numPixel, const // pack the generated LZW data into blocks of 255 bytes uint8_t *byteList; // lzw-data packed in byte-list uint8_t *byteListBlock; // lzw-data packed in byte-list with 255-block structure - uint64_t MaxByteListLen = MAX_CODE_LEN * lzwPos / 8ull + 2ull + 1ull; // conservative upper bound - uint64_t MaxByteListBlockLen = MAX_CODE_LEN * lzwPos * (BLOCK_SIZE + 1ull) / 8ull / BLOCK_SIZE + 2ull + 1ull +1ull; // conservative upper bound + uint64_t MaxByteListLen = (uint64_t)MAX_CODE_LEN * lzwPos / 8ull + 2ull + 1ull; // conservative upper bound + uint64_t MaxByteListBlockLen = (uint64_t)MAX_CODE_LEN * lzwPos * (BLOCK_SIZE + 1ull) / 8ull / BLOCK_SIZE + 2ull + 1ull +1ull; // conservative upper bound byteList = malloc(MaxByteListLen); byteListBlock = malloc(MaxByteListBlockLen); if(byteList == NULL || byteListBlock == NULL) {