forked from old/legacy-imlib2
Check filename before opening archive file.
Summary: Decompressing should be the last step, otherwise files that can't even be loaded will take unnecessarily long only to be discarded immediately. This is in reference to [this issue for feh](https://github.com/derf/feh/issues/477) complaining about long load times in case of accidentally trying to open a big .tar.bz2 archive. Test Plan: Ran on sample from aforementioned ticket, observed immediate response and no further ill effects. Reviewers: kwo Differential Revision: https://phab.enlightenment.org/D10398
This commit is contained in:
parent
ab918a65ac
commit
ff3164df37
|
@ -62,14 +62,25 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
if (!p || p == im->real_file || strcasecmp(p + 1, "bz2") || p == q)
|
||||
return 0;
|
||||
|
||||
if (!(real_ext = strndup(im->real_file, p - im->real_file)))
|
||||
return 0;
|
||||
|
||||
if (!(loader = __imlib_FindBestLoaderForFile(real_ext, 0)))
|
||||
{
|
||||
free(real_ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(fp = fopen(im->real_file, "rb")))
|
||||
{
|
||||
free(real_ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((dest = mkstemp(tmp)) < 0)
|
||||
{
|
||||
fclose(fp);
|
||||
free(real_ext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,15 +89,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
close(dest);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
unlink(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(real_ext = strndup(im->real_file, p - im->real_file)))
|
||||
return 0;
|
||||
|
||||
if (!(loader = __imlib_FindBestLoaderForFile(real_ext, 0)))
|
||||
{
|
||||
free(real_ext);
|
||||
unlink(tmp);
|
||||
|
|
Loading…
Reference in New Issue