Skip to content

Commit

Permalink
Fix for Issue #750 - potential crash if we remove current file from list
Browse files Browse the repository at this point in the history
  • Loading branch information
nigels-com committed Dec 20, 2024
1 parent 565bc67 commit 95427e6
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/slideshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ void slideshow_change_image(winwidget winwid, int change, int render)
break;
}

if (last) {
/* Ignore an errored file in future, if possible (and safe) */
if (last && last != current_file) {
filelist = feh_file_remove_from_list(filelist, last);
last = NULL;
}
Expand All @@ -336,27 +337,26 @@ void slideshow_change_image(winwidget winwid, int change, int render)
}

if (winwidget_loadimage(winwid, FEH_FILE(current_file->data))) {
int w = gib_imlib_image_get_width(winwid->im);
int h = gib_imlib_image_get_height(winwid->im);
if (feh_should_ignore_image(winwid->im)) {
last = current_file;
continue;
}
winwid->mode = MODE_NORMAL;
winwid->file = current_file;
if ((winwid->im_w != w) || (winwid->im_h != h))
winwid->had_resize = 1;
winwidget_reset_image(winwid);
winwid->im_w = w;
winwid->im_h = h;
if (render) {
winwidget_render_image(winwid, 1, 0);
if (!feh_should_ignore_image(winwid->im)) {
int w = gib_imlib_image_get_width(winwid->im);
int h = gib_imlib_image_get_height(winwid->im);
winwid->mode = MODE_NORMAL;
winwid->file = current_file;
if ((winwid->im_w != w) || (winwid->im_h != h))
winwid->had_resize = 1;
winwidget_reset_image(winwid);
winwid->im_w = w;
winwid->im_h = h;
if (render) {
winwidget_render_image(winwid, 1, 0);
}
break; /* Happy path */
}
break;
} else
last = current_file;
}

last = current_file;
}
if (last)
if (last && last != current_file)
filelist = feh_file_remove_from_list(filelist, last);

if (filelist_len == 0)
Expand Down

0 comments on commit 95427e6

Please sign in to comment.