loaders: Ensure that found loader is ok for load/save
Fixes a segv that could happen if trying to save an image with a not previously loaded loader that has no saver. Bug since v1.7.5.
This commit is contained in:
parent
c13f4ddf65
commit
d56be3b8df
|
@ -280,6 +280,12 @@ __imlib_LookupKnownLoader(const char *format)
|
|||
return l;
|
||||
}
|
||||
|
||||
static int
|
||||
_loader_ok_for(const ImlibLoader * l, int for_save)
|
||||
{
|
||||
return (for_save && l->save) || (!for_save && (l->load2 || l->load));
|
||||
}
|
||||
|
||||
static ImlibLoader *
|
||||
__imlib_LookupLoadedLoader(const char *format, int for_save)
|
||||
{
|
||||
|
@ -310,8 +316,7 @@ __imlib_LookupLoadedLoader(const char *format, int for_save)
|
|||
if (strcasecmp(l->formats[i], format) == 0)
|
||||
{
|
||||
/* does it provide the function we need? */
|
||||
if ((for_save && l->save) ||
|
||||
(!for_save && (l->load2 || l->load)))
|
||||
if (_loader_ok_for(l, for_save))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
@ -344,7 +349,7 @@ __imlib_FindBestLoader(const char *file, const char *format, int for_save)
|
|||
}
|
||||
|
||||
l = __imlib_LookupKnownLoader(format);
|
||||
if (l)
|
||||
if (l && _loader_ok_for(l, for_save))
|
||||
goto done;
|
||||
|
||||
__imlib_LoadAllLoaders();
|
||||
|
|
Loading…
Reference in New Issue