]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fix event leak if purging dovecot.index.cache fails
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 5 Feb 2023 18:46:34 +0000 (20:46 +0200)
committermarkus.valentin <markus.valentin@open-xchange.com>
Tue, 28 Feb 2023 12:09:54 +0000 (12:09 +0000)
src/lib-index/mail-cache-purge.c

index b93860627c43b8cbc53dbaeac478570258ea9601..ad57c208602e4e3582f012ccf4f5cb3d79969466 100644 (file)
@@ -392,17 +392,21 @@ mail_cache_purge_write(struct mail_cache *cache,
 
        if (mail_cache_copy(cache, trans, event, fd, reason,
                            &file_seq, &file_size, &max_uid,
-                           &ext_first_seq, &ext_offsets) < 0)
+                           &ext_first_seq, &ext_offsets) < 0) {
+               event_unref(&event);
                return -1;
+       }
 
        if (fstat(fd, &st) < 0) {
                mail_cache_set_syscall_error(cache, "fstat()");
                array_free(&ext_offsets);
+               event_unref(&event);
                return -1;
        }
        if (rename(temp_path, cache->filepath) < 0) {
                mail_cache_set_syscall_error(cache, "rename()");
                array_free(&ext_offsets);
+               event_unref(&event);
                return -1;
        }