Fixed segfault on image removal with uninitialized thumbnails; fixes issue #177
This commit is contained in:
parent
ddd028eb3e
commit
8db3191f04
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
VERSION = git-20140930
|
VERSION = git-20141001
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
MANPREFIX = $(PREFIX)/share/man
|
MANPREFIX = $(PREFIX)/share/man
|
||||||
|
|
9
main.c
9
main.c
|
@ -177,12 +177,13 @@ void remove_file(int n, bool manual)
|
||||||
free((void*) files[n].name);
|
free((void*) files[n].name);
|
||||||
|
|
||||||
if (n + 1 < filecnt) {
|
if (n + 1 < filecnt) {
|
||||||
memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(fileinfo_t));
|
if (tns.thumbs != NULL) {
|
||||||
memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) *
|
memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) *
|
||||||
sizeof(thumb_t));
|
sizeof(*tns.thumbs));
|
||||||
memset(tns.thumbs + filecnt - 1, 0, sizeof(thumb_t));
|
memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs));
|
||||||
|
}
|
||||||
|
memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files));
|
||||||
}
|
}
|
||||||
|
|
||||||
filecnt--;
|
filecnt--;
|
||||||
if (fileidx >= filecnt)
|
if (fileidx >= filecnt)
|
||||||
fileidx = filecnt - 1;
|
fileidx = filecnt - 1;
|
||||||
|
|
Loading…
Reference in a new issue