aboutsummaryrefslogtreecommitdiffstats
path: root/src/gif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gif.c')
-rw-r--r--src/gif.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gif.c b/src/gif.c
index 78400f2..977e8df 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -17,12 +17,25 @@ struct gif_t{
GifFileType *gif;
};
+static int isgif(FILE *f){
+ return (getc(f) == 'G' && getc(f) == 'I' && getc(f) == 'F');
+}
+
static struct image *gif_open(FILE *f){
struct gif_t *g;
GifFileType *gif;
+ rewind(f);
+ if(!isgif(f))
+ return NULL;
+
+ /* HACK HACK HACK */
+ rewind(f);
lseek(fileno(f), 0L, SEEK_SET);
if(!(gif = DGifOpenFileHandle(fileno(f)))){
+ /* HACK AND HOPE */
+ rewind(f);
+ lseek(fileno(f), 0L, SEEK_SET);
return NULL;
}
g = malloc(sizeof(struct gif_t));
@@ -36,7 +49,7 @@ static struct image *gif_open(FILE *f){
}
static int gif_read(struct image *img){
- int i, j = 0;
+ unsigned int i, j = 0;
struct gif_t *g = (struct gif_t *)img;
GifColorType *colormap;
SavedImage *s;