changeset 19061:5c444f10cef9

dict-sql: Fixed memory leak when committing/rollbacking unchanged transaction.
author Timo Sirainen <tss@iki.fi>
date Wed, 02 Sep 2015 17:26:08 +0300
parents 46eb03d95feb
children cb6d6d861ffa
files src/lib-dict/dict-sql.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-dict/dict-sql.c	Wed Sep 02 17:23:45 2015 +0300
+++ b/src/lib-dict/dict-sql.c	Wed Sep 02 17:26:08 2015 +0300
@@ -546,7 +546,10 @@
 	if (ctx->failed) {
 		sql_transaction_rollback(&ctx->sql_ctx);
 		ret = -1;
-	} else if (_ctx->changed) {
+	} else if (!_ctx->changed) {
+		/* nothing changed, no need to commit */
+		sql_transaction_rollback(&ctx->sql_ctx);
+	} else {
 		if (sql_transaction_commit_s(&ctx->sql_ctx, &error) < 0) {
 			i_error("sql dict: commit failed: %s", error);
 			ret = -1;
@@ -576,8 +579,7 @@
 	struct sql_dict_transaction_context *ctx =
 		(struct sql_dict_transaction_context *)_ctx;
 
-	if (_ctx->changed)
-		sql_transaction_rollback(&ctx->sql_ctx);
+	sql_transaction_rollback(&ctx->sql_ctx);
 
 	if (ctx->inc_row_pool != NULL)
 		pool_unref(&ctx->inc_row_pool);