From: Timo Sirainen Date: Mon, 27 Sep 2010 18:53:07 +0000 (+0100) Subject: sdbox: Fixed memory leak when copying messages with hard links. X-Git-Tag: 2.0.5~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c50ccaa9adb7df8cb49a240909fce732da57bed;p=thirdparty%2Fdovecot%2Fcore.git sdbox: Fixed memory leak when copying messages with hard links. --- diff --git a/src/lib-storage/index/dbox-single/sdbox-copy.c b/src/lib-storage/index/dbox-single/sdbox-copy.c index 5e122dd9ee..5a5a91e5b2 100644 --- a/src/lib-storage/index/dbox-single/sdbox-copy.c +++ b/src/lib-storage/index/dbox-single/sdbox-copy.c @@ -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; }