Skip to content

Commit 9b8b9bf

Browse files
committed
fix: cast to uint64_t before LZW buffer length calc
1 parent b1facf7 commit 9b8b9bf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/cgif_raw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ static int LZW_GenerateStream(LZWResult* pResult, const uint32_t numPixel, const
349349
// pack the generated LZW data into blocks of 255 bytes
350350
uint8_t *byteList; // lzw-data packed in byte-list
351351
uint8_t *byteListBlock; // lzw-data packed in byte-list with 255-block structure
352-
uint64_t MaxByteListLen = MAX_CODE_LEN * lzwPos / 8ull + 2ull + 1ull; // conservative upper bound
353-
uint64_t MaxByteListBlockLen = MAX_CODE_LEN * lzwPos * (BLOCK_SIZE + 1ull) / 8ull / BLOCK_SIZE + 2ull + 1ull +1ull; // conservative upper bound
352+
uint64_t MaxByteListLen = (uint64_t)MAX_CODE_LEN * lzwPos / 8ull + 2ull + 1ull; // conservative upper bound
353+
uint64_t MaxByteListBlockLen = (uint64_t)MAX_CODE_LEN * lzwPos * (BLOCK_SIZE + 1ull) / 8ull / BLOCK_SIZE + 2ull + 1ull +1ull; // conservative upper bound
354354
byteList = malloc(MaxByteListLen);
355355
byteListBlock = malloc(MaxByteListBlockLen);
356356
if(byteList == NULL || byteListBlock == NULL) {

0 commit comments

Comments
 (0)