changeset 21657:69f21a7bd37e

lib-index: Add missing initialization for chained hooks
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 20 Feb 2017 15:35:02 +0200
parents 538853d82926
children bd1d7007cb01
files src/lib-index/mail-index-transaction-private.h src/lib-index/mail-index-transaction.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-private.h	Mon Feb 20 15:28:36 2017 +0200
+++ b/src/lib-index/mail-index-transaction-private.h	Mon Feb 20 15:35:02 2017 +0200
@@ -26,6 +26,7 @@
 };
 
 union mail_index_transaction_module_context {
+	struct mail_index_transaction_vfuncs super;
 	struct mail_index_module_register *reg;
 };
 
@@ -40,7 +41,7 @@
 	int refcount;
 
 	enum mail_index_transaction_flags flags;
-	struct mail_index_transaction_vfuncs v;
+	struct mail_index_transaction_vfuncs v, *vlast;
 	struct mail_index_view *view;
 	struct mail_index_view *latest_view;
 
--- a/src/lib-index/mail-index-transaction.c	Mon Feb 20 15:28:36 2017 +0200
+++ b/src/lib-index/mail-index-transaction.c	Mon Feb 20 15:35:02 2017 +0200
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "ioloop.h"
 #include "array.h"
+#include "hook-build.h"
 #include "bsearch-insert-pos.h"
 #include "llist.h"
 #include "mail-index-private.h"
@@ -349,10 +350,15 @@
 	DLLIST_PREPEND(&view->transactions_list, t);
 
 	if (array_is_created(&hook_mail_index_transaction_created)) {
+	        struct hook_build_context *ctx =
+			hook_build_init((void *)&t->v, sizeof(t->v));
 		const hook_mail_index_transaction_created_t *const *ptr;
 		array_foreach(&hook_mail_index_transaction_created, ptr) {
 			(*ptr)(t);
+			hook_build_update(ctx, t->vlast);
 		}
+		t->vlast = NULL;
+		hook_build_deinit(&ctx);
 	}
 	return t;
 }