]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
sdbox: Fixed memory leak when copying messages with hard links.
authorTimo Sirainen <tss@iki.fi>
Mon, 27 Sep 2010 18:53:07 +0000 (19:53 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 27 Sep 2010 18:53:07 +0000 (19:53 +0100)
src/lib-storage/index/dbox-single/sdbox-copy.c

index 5e122dd9ee0964d03773d227ce9f0d6bb5dca3ae..5a5a91e5b2aed69a5789ebb93445e8be5e09524b 100644 (file)
@@ -36,9 +36,8 @@ sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail)
        }
        if (ret < 0) {
                if (ECANTLINK(errno))
-                       return 0;
-
-               if (errno == ENOENT)
+                       ret = 0;
+               else if (errno == ENOENT)
                        mail_set_expunged(mail);
                else {
                        mail_storage_set_critical(
@@ -46,7 +45,9 @@ sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail)
                                "link(%s, %s) failed: %m",
                                src_path, dest_file->cur_path);
                }
-               return -1;
+               dbox_file_unref(&src_file);
+               dbox_file_unref(&dest_file);
+               return ret;
        }
 
        dbox_save_add_to_index(ctx);
@@ -55,6 +56,7 @@ sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail)
                mail_set_seq(_ctx->dest_mail, ctx->seq);
                _ctx->dest_mail->saving = TRUE;
        }
+       dbox_file_unref(&src_file);
        return 1;
 }