fix: thumbnail memory leak when removing file (#247)

This commit is contained in:
N-R-K 2022-03-27 09:34:44 +00:00 committed by GitHub
parent 590d9fe0a9
commit bf6c062779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

4
main.c
View file

@ -165,6 +165,10 @@ void remove_file(int n, bool manual)
if (n + 1 < filecnt) { if (n + 1 < filecnt) {
if (tns.thumbs != NULL) { if (tns.thumbs != NULL) {
if (tns.thumbs[n].im != NULL) {
imlib_context_set_image(tns.thumbs[n].im);
imlib_free_image_and_decache();
}
memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) * memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) *
sizeof(*tns.thumbs)); sizeof(*tns.thumbs));
memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs)); memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs));