Mercurial > dovecot > core-2.2
changeset 18840:34943b67e01f
cassandra: Minor code cleanup to make sure we don't try to access freed transaction memory.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 11 Jun 2015 15:28:46 +0300 |
parents | 247c6ae2eae4 |
children | 34fad121ec7b |
files | src/lib-sql/driver-cassandra.c |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-sql/driver-cassandra.c Thu Jun 11 15:28:05 2015 +0300 +++ b/src/lib-sql/driver-cassandra.c Thu Jun 11 15:28:46 2015 +0300 @@ -769,8 +769,11 @@ } static void -driver_cassandra_transaction_unref(struct cassandra_transaction_context *ctx) +driver_cassandra_transaction_unref(struct cassandra_transaction_context **_ctx) { + struct cassandra_transaction_context *ctx = *_ctx; + + *_ctx = NULL; i_assert(ctx->refcount > 0); if (--ctx->refcount > 0) return; @@ -790,7 +793,7 @@ } else { ctx->begin_succeeded = TRUE; } - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); } static void @@ -801,7 +804,7 @@ ctx->callback(sql_result_get_error(result), ctx->context); else ctx->callback(NULL, ctx->context); - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); } static void @@ -815,7 +818,7 @@ ctx->failed = TRUE; ctx->error = sql_result_get_error(result); } - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); } static void @@ -830,7 +833,7 @@ if (ctx->failed || _ctx->head == NULL) { callback(ctx->failed ? ctx->error : NULL, context); - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); } else if (_ctx->head->next == NULL) { /* just a single query, send it */ sql_query(_ctx->db, _ctx->head->query, @@ -942,7 +945,7 @@ i_assert(ctx->refcount == 1); i_assert((*error_r != NULL) == ctx->failed); - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); return *error_r == NULL ? 0 : -1; } @@ -953,7 +956,7 @@ (struct cassandra_transaction_context *)_ctx; i_assert(ctx->refcount == 1); - driver_cassandra_transaction_unref(ctx); + driver_cassandra_transaction_unref(&ctx); } static void