Skip to content

Commit

Permalink
applied giflib patch from Jan Engelhardt
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskramm committed Jul 6, 2013
1 parent c514a78 commit 05c1df6
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/gif2swf.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id, int imgidx)

GifFileType *gft;
FILE *fi;
int ret;

if ((fi = fopen(sname, "rb")) == NULL) {
if (VERBOSE(1))
Expand All @@ -230,13 +231,22 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id, int imgidx)
}
fclose(fi);

if ((gft = DGifOpenFileName(sname)) == NULL) {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
gft = DGifOpenFileName(sname, NULL);
#else
gft = DGifOpenFileName(sname);
#endif
if (gft == NULL) {
fprintf(stderr, "%s is not a GIF file!\n", sname);
return t;
}

if (DGifSlurp(gft) != GIF_OK) {
if ((ret = DGifSlurp(gft)) != GIF_OK) {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
fprintf(stderr, "GIF-LIB: %s\n", GifErrorString(ret));
#else
PrintGifError();
#endif
return t;
}

Expand Down Expand Up @@ -465,6 +475,7 @@ int CheckInputFile(char *fname, char **realname)
FILE *fi;
char *s = malloc(strlen(fname) + 5);
GifFileType *gft;
int ret;

if (!s)
exit(2);
Expand All @@ -488,7 +499,12 @@ int CheckInputFile(char *fname, char **realname)
}
fclose(fi);

if ((gft = DGifOpenFileName(s)) == NULL) {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
gft = DGifOpenFileName(s, NULL);
#else
gft = DGifOpenFileName(s);
#endif
if (gft == NULL) {
fprintf(stderr, "%s is not a GIF file!\n", fname);
return -1;
}
Expand All @@ -498,8 +514,12 @@ int CheckInputFile(char *fname, char **realname)
if (global.max_image_height < gft->SHeight)
global.max_image_height = gft->SHeight;

if (DGifSlurp(gft) != GIF_OK) {
if ((ret = DGifSlurp(gft)) != GIF_OK) {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
fprintf(stderr, "GIF-LIB: %s\n", GifErrorString(ret));
#else
PrintGifError();
#endif
return -1;
}
// After DGifSlurp() call, gft->ImageCount become available
Expand Down

0 comments on commit 05c1df6

Please sign in to comment.