diff --git a/src/image.c b/src/image.c index 941616d..1b51220 100644 --- a/src/image.c +++ b/src/image.c @@ -1148,9 +1148,12 @@ __imlib_LoadImage(const char *file, ImlibProgressFunction progress, *er = LOAD_ERROR_OUT_OF_MEMORY; else if (errno == EMFILE) *er = LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS; - /* free the stuct we created */ - __imlib_ConsumeImage(im); - return NULL; + if (*er != LOAD_ERROR_UNKNOWN) + { + /* free the stuct we created */ + __imlib_ConsumeImage(im); + return NULL; + } } errno = 0; }