summaryrefslogtreecommitdiff
path: root/generators.c
diff options
context:
space:
mode:
Diffstat (limited to 'generators.c')
-rw-r--r--generators.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/generators.c b/generators.c
index 0a1585c..810a0d9 100644
--- a/generators.c
+++ b/generators.c
@@ -55,7 +55,14 @@ generate_image (TGallerySetup *setup,
int bigq;
+ *img_src = NULL;
+ *thumb = NULL;
+ *img_w = 0;
+ *img_h = 0;
+
if (items->type == GALLERY_TYPE_INDEX) {
+ if (item->thumbnail == NULL || strlen (item->thumbnail) == 0)
+ return;
img_src_full = g_strconcat (items->base_dir, "/", item->thumbnail, NULL);
thumb_src_full = g_strconcat (items->base_dir, "/", item->thumbnail, NULL);
*img_src = g_path_get_basename (item->thumbnail);
@@ -440,7 +447,7 @@ write_html_album (TGallerySetup *setup,
case INDEX_ITEM_TYPE_PICTURE:
generate_image (setup, items, item, dst, &img_w, &img_h, &img_src, &thumb);
/* Process HTML box code */
- if ((img_w / img_h) >= 1)
+ if (img_w == 0 || img_h == 0 || (img_w / img_h) >= 1)
s1 = strdup (buf_img_list_landscape);
else
s1 = strdup (buf_img_list_portrait);
@@ -906,7 +913,7 @@ build_tree (TGallerySetup *setup,
#endif
/* Check access permissions */
- if (access (src_tree, R_OK | X_OK)) {
+ if (access (src_tree, R_OK)) {
fprintf (stderr, "error accessing source directory: %s\n", strerror (errno));
return FALSE;
}
@@ -919,7 +926,7 @@ build_tree (TGallerySetup *setup,
/* Check the index file */
idx_file = g_strconcat (src_tree, "/index.xml", NULL);
- if (access (src_tree, R_OK | X_OK)) {
+ if (access (idx_file, R_OK)) {
fprintf (stderr, "error accessing index file '%s': %s\n", idx_file, strerror (errno));
g_free (idx_file);
return FALSE;
@@ -927,6 +934,7 @@ build_tree (TGallerySetup *setup,
/* Read the index file and fill items array */
items = malloc (sizeof (TAlbum));
+ memset (items, 0, sizeof (TAlbum));
if (! parse_album_xml (idx_file, items)) {
fprintf (stderr, "error reading index file '%s'\n", idx_file);
g_free (idx_file);