diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c index 1332d8c..fece782 100644 --- a/src/modules/loaders/loader_gif.c +++ b/src/modules/loaders/loader_gif.c @@ -27,19 +27,18 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (fd < 0) return LOAD_FAIL; + rc = LOAD_FAIL; + done = 0; + rows = NULL; + transp = -1; + #if GIFLIB_MAJOR >= 5 gif = DGifOpenFileHandle(fd, NULL); #else gif = DGifOpenFileHandle(fd); #endif - close(fd); if (!gif) - return LOAD_FAIL; - - rc = LOAD_FAIL; - done = 0; - rows = NULL; - transp = -1; + goto quit; do { @@ -185,11 +184,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, free(rows); } + if (gif) + { #if GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1) - DGifCloseFile(gif, NULL); + DGifCloseFile(gif, NULL); #else - DGifCloseFile(gif); + DGifCloseFile(gif); #endif + } + + close(fd); if (rc <= 0) __imlib_FreeData(im);