Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix "pixel overrun"
fixes #3
  • Loading branch information
miniupnp committed May 3, 2018
1 parent b588a22 commit cf429e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ngiflib.c
Expand Up @@ -528,7 +528,8 @@ static int DecodeGifImg(struct ngiflib_img * i) {
act_code = GetGifWord(i, &context);
casspecial = (u8)act_code;
old_code = act_code;
WritePixel(i, &context, casspecial); npix--;
if(npix > 0) WritePixel(i, &context, casspecial);
npix--;
} else {
read_byt = act_code;
if(act_code >= free) { /* code pas encore dans alphabet */
Expand All @@ -545,7 +546,11 @@ static int DecodeGifImg(struct ngiflib_img * i) {
/* act_code est concret */
casspecial = (u8)act_code; /* dernier debut de chaine ! */
*(--stackp) = casspecial; /* push on stack */
WritePixels(i, &context, stackp, stack_top - stackp); /* unstack all pixels at once */
if(npix >= (stack_top - stackp)) {
WritePixels(i, &context, stackp, stack_top - stackp); /* unstack all pixels at once */
} else if(npix > 0) { /* "pixel overflow" */
WritePixels(i, &context, stackp, npix);
}
npix -= (stack_top - stackp);
stackp = stack_top;
/* putchar('\n'); */
Expand Down

0 comments on commit cf429e0

Please sign in to comment.