diff --git a/rwgif.c b/rwgif.c
index 7aa4b5e..0fd63ee 100644
--- a/rwgif.c
+++ b/rwgif.c
@@ -46,7 +46,7 @@ open_gif_file (const char *filename, int *width, int *height)
     GifRecordType record_type;
     GifRowType *buffer = NULL;
     
-    int i, j;
+    int i, j, gif_err;
     int color_index;
     unsigned char *ptr = NULL;
                 
@@ -54,7 +54,7 @@ open_gif_file (const char *filename, int *width, int *height)
     
     assert(data != 0);
     
-    data->file = DGifOpenFileName(filename);
+    data->file = DGifOpenFileName(filename, &gif_err);
     
     assert(data->file !=0);
         
@@ -137,7 +137,7 @@ open_gif_file (const char *filename, int *width, int *height)
     }
     free(buffer);
     
-    assert(DGifCloseFile(data->file) == GIF_OK);
+    assert(DGifCloseFile(data->file, &gif_err) == GIF_OK);
     
     return data;
 }
