From: Timo Sirainen Date: Mon, 13 Feb 2017 21:34:25 +0000 (+0200) Subject: dict-sql: Fix error handling in commit X-Git-Tag: 2.3.0.rc1~2121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b08d9d9be3db241a92cc072feab21d1e0e24a58;p=thirdparty%2Fdovecot%2Fcore.git dict-sql: Fix error handling in commit sql_dict_prev_inc_flush() or sql_dict_prev_set_flush() might set ctx->error, so they need to be done earlier. --- diff --git a/src/lib-dict/dict-sql.c b/src/lib-dict/dict-sql.c index c04b06cef6..f1ac6385d8 100644 --- a/src/lib-dict/dict-sql.c +++ b/src/lib-dict/dict-sql.c @@ -844,15 +844,16 @@ sql_dict_transaction_commit(struct dict_transaction_context *_ctx, bool async, const char *error; struct dict_commit_result result; - i_zero(&result); - result.ret = DICT_COMMIT_RET_FAILED; - result.error = t_strdup(ctx->error); - if (ctx->prev_inc_map != NULL) sql_dict_prev_inc_flush(ctx); if (ctx->prev_set_map != NULL) sql_dict_prev_set_flush(ctx); + /* note that the above calls might still set ctx->error */ + i_zero(&result); + result.ret = DICT_COMMIT_RET_FAILED; + result.error = t_strdup(ctx->error); + if (ctx->error != NULL) { sql_transaction_rollback(&ctx->sql_ctx); } else if (!_ctx->changed) {