Skip to content

Commit a64816a

Browse files
authored
fix potential integer overflow in raw API (#103)
1 parent dcd45c7 commit a64816a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cgif_raw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static int LZW_GenerateStream(LZWResult* pResult, const uint32_t numPixel, const
330330
// where N = max dictionary resets = numPixel / (MAX_DICT_LEN - initDictLen - 2)
331331
entriesPerCycle = MAX_DICT_LEN - initDictLen - 2; // maximum added number of dictionary entries per cycle: -2 to account for start and end code
332332
maxResets = numPixel / entriesPerCycle;
333-
pContext->pLZWData = malloc(sizeof(uint16_t) * (numPixel + 2 + maxResets));
333+
pContext->pLZWData = malloc(sizeof(uint16_t) * ((size_t)numPixel + 2 + maxResets));
334334
if(pContext->pLZWData == NULL) {
335335
r = CGIF_EALLOC;
336336
goto LZWGENERATE_Cleanup;

0 commit comments

Comments
 (0)