--- wrlib/gif.c.orig	2013-01-12 17:36:51.015744230 +0100
+++ wrlib/gif.c	2013-01-12 17:47:33.992447587 +0100
@@ -43,7 +43,7 @@ RImage *RLoadGIF(char *file, int index)
 	unsigned char *cptr;
 	GifFileType *gif = NULL;
 	GifPixelType *buffer = NULL;
-	int i, j, k;
+	int i, j, k, err = 0;
 	int width, height;
 	GifRecordType recType;
 	ColorMapObject *colormap;
@@ -57,10 +57,10 @@ RImage *RLoadGIF(char *file, int index)
 	/* default error message */
 	RErrorCode = RERR_BADINDEX;
 
-	gif = DGifOpenFileName(file);
+	gif = DGifOpenFileName(file, &err);
 
-	if (!gif) {
-		switch (GifLastError()) {
+	if (err) {
+		switch (err) {
 		case D_GIF_ERR_OPEN_FAILED:
 			RErrorCode = RERR_OPEN;
 			break;
@@ -197,7 +197,7 @@ RImage *RLoadGIF(char *file, int index)
 	/* yuck! */
 	goto did_not_get_any_errors;
  giferr:
-	switch (GifLastError()) {
+	switch (gif->Error) {
 	case D_GIF_ERR_OPEN_FAILED:
 		RErrorCode = RERR_OPEN;
 		break;