summaryrefslogtreecommitdiffstats
path: root/thumbs.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2016-10-20 10:21:55 +0200
committerBert Münnich <ber.t@posteo.de>2016-10-20 10:21:55 +0200
commit878d97068cb6c8ae044332ac3c8218fcad635b42 (patch)
tree1282bbed9d2743baafd23d9aad8ec02d2d9d7ca7 /thumbs.c
parent891f389f0e228759b05dadec9dafdea5dc772f70 (diff)
downloadnsxiv-878d97068cb6c8ae044332ac3c8218fcad635b42.tar.zst
Only open regular files; fixes issue #252
Diffstat (limited to 'thumbs.c')
-rw-r--r--thumbs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/thumbs.c b/thumbs.c
index 3988bd2..43bb50c 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -239,6 +239,7 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
float zw, zh;
thumb_t *t;
fileinfo_t *file;
+ struct stat st;
Imlib_Image im = NULL;
if (n < 0 || n >= *tns->cnt)
@@ -330,12 +331,15 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only)
}
}
- if (im == NULL && (access(file->path, R_OK) < 0 ||
- (im = imlib_load_image(file->path)) == NULL))
- {
- if (file->flags & FF_WARN)
- error(0, 0, "%s: Error opening image", file->name);
- return false;
+ if (im == NULL) {
+ if (access(file->path, R_OK) == -1 ||
+ stat(file->path, &st) == -1 || !S_ISREG(st.st_mode) ||
+ (im = imlib_load_image(file->path)) == NULL)
+ {
+ if (file->flags & FF_WARN)
+ error(0, 0, "%s: Error opening image", file->name);
+ return false;
+ }
}
imlib_context_set_image(im);