Skip to content

Commit

Permalink
fix npix counting
Browse files Browse the repository at this point in the history
bug introduced in cf429e0
fixes #25
  • Loading branch information
miniupnp committed Jun 29, 2023
1 parent 5e7292b commit fb2713a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ngiflib.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,10 @@ static int DecodeGifImg(struct ngiflib_img * i) {
}
casspecial = (u8)act_code;
old_code = act_code;
if(npix > 0) WritePixel(i, &context, casspecial);
npix--;
if(npix > 0) {
WritePixel(i, &context, casspecial);
npix--;
}
} else if(act_code > free) {
#if !defined(NGIFLIB_NO_FILE)
if(i->parent && i->parent->log) fprintf(i->parent->log, "Invalid code %hu (free=%hu) !\n", act_code, free);
Expand All @@ -610,10 +612,11 @@ static int DecodeGifImg(struct ngiflib_img * i) {
*(--stackp) = casspecial; /* push on stack */
if(npix >= (stack_top - stackp)) {
WritePixels(i, &context, stackp, stack_top - stackp); /* unstack all pixels at once */
npix -= (stack_top - stackp);
} else if(npix > 0) { /* "pixel overflow" */
WritePixels(i, &context, stackp, npix);
npix = 0;
}
npix -= (stack_top - stackp);
stackp = stack_top;
/* putchar('\n'); */
if(free < 4096) { /* la taille du dico est 4096 max ! */
Expand Down

0 comments on commit fb2713a

Please # to comment.