Skip to content

Commit

Permalink
fix potential crash on 32-bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
dloebl committed Jun 18, 2024
1 parent 10760e0 commit 31d9040
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cgif_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,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/8ul +2ul +1ul; // conservative upper bound
uint64_t MaxByteListBlockLen = MAX_CODE_LEN*lzwPos*(BLOCK_SIZE+1ul)/8ul/BLOCK_SIZE +2ul +1ul +1ul; // conservative upper bound
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
byteList = malloc(MaxByteListLen); // TBD check return value of malloc
byteListBlock = malloc(MaxByteListBlockLen); // TBD check return value of malloc
bytePos = create_byte_list(byteList,lzwPos, pContext->pLZWData, initDictLen, initCodeLen);
Expand Down

0 comments on commit 31d9040

Please sign in to comment.