]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-sql: Fix error handling in commit
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 13 Feb 2017 21:34:25 +0000 (23:34 +0200)
committerGitLab <gitlab@git.dovecot.net>
Tue, 14 Feb 2017 11:55:06 +0000 (13:55 +0200)
sql_dict_prev_inc_flush() or sql_dict_prev_set_flush() might set ctx->error,
so they need to be done earlier.

src/lib-dict/dict-sql.c

index c04b06cef62ba19f7bed8bf393f1caf472a5e555..f1ac6385d8b44425275d3180e2e04d5a5944e8c2 100644 (file)
@@ -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) {