Skip to content

Commit 857f29b

Browse files
committed
fix potential undefined behavior in cgif_addframe
1 parent 48d28fe commit 857f29b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/cgif.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static void copyFrameConfig(CGIF_FrameConfig* pDest, CGIF_FrameConfig* pSrc) {
464464
int cgif_addframe(CGIF* pGIF, CGIF_FrameConfig* pConfig) {
465465
CGIF_Frame* pNewFrame;
466466
int hasAlpha, hasSetTransp;
467-
int i;
467+
uint32_t i;
468468
cgif_result r;
469469

470470
// check for previous errors
@@ -502,7 +502,7 @@ int cgif_addframe(CGIF* pGIF, CGIF_FrameConfig* pConfig) {
502502
sameFrame = 0;
503503
}
504504
} else {
505-
for(i = 0; i < pGIF->config.width * pGIF->config.height; i++) {
505+
for(i = 0; i < MULU16(pGIF->config.width, pGIF->config.height); i++) {
506506
if(cmpPixel(pGIF, pConfig, &pGIF->aFrames[pGIF->iHEAD]->config, pConfig->pImageData[i], pGIF->aFrames[pGIF->iHEAD]->config.pImageData[i])) {
507507
sameFrame = 0;
508508
break;

0 commit comments

Comments
 (0)