diff options
author | Bert Münnich <ber.t@posteo.de> | 2014-10-01 20:25:36 +0200 |
---|---|---|
committer | Bert Münnich <ber.t@posteo.de> | 2014-10-01 20:25:36 +0200 |
commit | 8db3191f04d52929ec10b1412d282a4ac4cf5240 (patch) | |
tree | 0a70be5c813e489d327f03575e5ceee8224fb946 | |
parent | ddd028eb3ea628855b4bb35ca7fb40562bd87861 (diff) |
Fixed segfault on image removal with uninitialized thumbnails; fixes issue #177
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | main.c | 11 |
2 files changed, 7 insertions, 6 deletions
@@ -1,4 +1,4 @@ -VERSION = git-20140930 +VERSION = git-20141001 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man @@ -177,12 +177,13 @@ void remove_file(int n, bool manual) free((void*) files[n].name); if (n + 1 < filecnt) { - memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(fileinfo_t)); - memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) * - sizeof(thumb_t)); - memset(tns.thumbs + filecnt - 1, 0, sizeof(thumb_t)); + if (tns.thumbs != NULL) { + memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) * + sizeof(*tns.thumbs)); + memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs)); + } + memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files)); } - filecnt--; if (fileidx >= filecnt) fileidx = filecnt - 1; |