Skip to content
Permalink
Browse files Browse the repository at this point in the history
check GIF image position and dimensions
fixes #1
  • Loading branch information
miniupnp committed May 2, 2018
1 parent 75b9920 commit b588a22
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ngiflib.c
Expand Up @@ -408,6 +408,24 @@ static int DecodeGifImg(struct ngiflib_img * i) {
i->width = GetWord(i->parent); /* SizeX */
i->height = GetWord(i->parent); /* SizeY */

if((i->width > i->parent->width) || (i->height > i->parent->height)) {
#if !defined(NGIFLIB_NO_FILE)
if(i->parent->log) fprintf(i->parent->log, "*** ERROR *** Image bigger than global GIF canvas !\n");
#endif
return -1;
}
if((i->posX + i->width) > i->parent->width) {
#if !defined(NGIFLIB_NO_FILE)
if(i->parent->log) fprintf(i->parent->log, "*** WARNING *** Adjusting X position\n");
#endif
i->posX = i->parent->width - i->width;
}
if((i->posY + i->height) > i->parent->height) {
#if !defined(NGIFLIB_NO_FILE)
if(i->parent->log) fprintf(i->parent->log, "*** WARNING *** Adjusting Y position\n");
#endif
i->posY = i->parent->height - i->height;
}
context.Xtogo = i->width;
context.curY = i->posY;
#ifdef NGIFLIB_INDEXED_ONLY
Expand Down

0 comments on commit b588a22

Please sign in to comment.