]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Fix memory leak - unreference iostreams at deinit
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Jun 2018 17:07:28 +0000 (20:07 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 14 Jun 2018 07:43:06 +0000 (10:43 +0300)
Only some of the code paths need unreferencing, so also add a reference to
the other code paths.

src/doveadm/doveadm-dsync.c

index 194b3977ac8ab33ffaa57c7fcb1425666c9a14bb..718d5a0c0ae10d8527c3f54c4d3766b508ac11ae 100644 (file)
@@ -1176,6 +1176,8 @@ cmd_dsync_server_run(struct doveadm_mail_cmd_context *_ctx,
                ctx->fd_in = ctx->fd_out = -1;
                ctx->input = cctx->input;
                ctx->output = cctx->output;
+               i_stream_ref(ctx->input);
+               o_stream_ref(ctx->output);
                o_stream_set_finish_also_parent(ctx->output, FALSE);
                o_stream_nsend(ctx->output, "\n+\n", 3);
                i_set_failure_prefix("dsync-server(%s): ", user->username);
@@ -1218,6 +1220,8 @@ cmd_dsync_server_run(struct doveadm_mail_cmd_context *_ctx,
                   connection code */
                o_stream_close(cctx->output);
        }
+       i_stream_unref(&ctx->input);
+       o_stream_unref(&ctx->output);
 
        if (ctx->replicator_notify && _ctx->exit_code == 0)
                dsync_replicator_notify(ctx, sync_type, str_c(state_str));