[dovecot-cvs] dovecot/src/lib-index mail-index-transaction.c, 1.74, 1.75

tss-movial at dovecot.org tss-movial at dovecot.org
Mon Apr 24 12:17:16 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv31683

Modified Files:
	mail-index-transaction.c 
Log Message:
Fixed crash while updating keywords (broken by recent changes).



Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- mail-index-transaction.c	20 Apr 2006 14:10:11 -0000	1.74
+++ mail-index-transaction.c	24 Apr 2006 09:17:14 -0000	1.75
@@ -910,23 +910,18 @@
 
 		ARRAY_CREATE(&t->keyword_updates, default_pool,
 			     struct mail_index_transaction_keyword_update,
-			     max_idx);
+			     max_idx + 1);
 	}
 
 	/* Update add_seq and remove_seq arrays which describe the keyword
 	   changes. Don't bother updating remove_seq or keyword resets for
 	   newly added messages since they default to not having any
 	   keywords anyway. */
-	if (array_is_created(&t->keyword_updates))
-		ku = array_get_modifyable(&t->keyword_updates, &ku_count);
-	else {
-		ku = NULL;
-		ku_count = 0;
-	}
 	switch (modify_type) {
 	case MODIFY_ADD:
 		for (i = 0; i < keywords->count; i++) {
-			u = ku[keywords->idx[i]];
+			u = array_idx_modifyable(&t->keyword_updates,
+						 keywords->idx[i]);
 			seq_range_array_add(&u->add_seq, 16, seq);
 			if (seq < t->first_new_seq)
 				seq_range_array_remove(&u->remove_seq, seq);
@@ -934,7 +929,8 @@
 		break;
 	case MODIFY_REMOVE:
 		for (i = 0; i < keywords->count; i++) {
-			u = ku[keywords->idx[i]];
+			u = array_idx_modifyable(&t->keyword_updates,
+						 keywords->idx[i]);
 			seq_range_array_remove(&u->add_seq, seq);
 			if (seq < t->first_new_seq)
 				seq_range_array_add(&u->remove_seq, 16, seq);
@@ -942,14 +938,21 @@
 		break;
 	case MODIFY_REPLACE:
 		/* Remove sequence from all add/remove arrays */
-		for (i = 0; i < ku_count; i++) {
-			seq_range_array_remove(&ku[i]->add_seq, seq);
-			if (seq < t->first_new_seq)
-				seq_range_array_remove(&ku[i]->remove_seq, seq);
+		if (array_is_created(&t->keyword_updates)) {
+			ku = array_get_modifyable(&t->keyword_updates,
+						  &ku_count);
+			for (i = 0; i < ku_count; i++) {
+				seq_range_array_remove(&ku[i]->add_seq, seq);
+				if (seq < t->first_new_seq) {
+					seq_range_array_remove(
+						&ku[i]->remove_seq, seq);
+				}
+			}
 		}
 		/* Add the wanted keyword back */
 		for (i = 0; i < keywords->count; i++) {
-			u = ku[keywords->idx[i]];
+			u = array_idx_modifyable(&t->keyword_updates,
+						 keywords->idx[i]);
 			seq_range_array_add(&u->add_seq, 16, seq);
 		}
 



More information about the dovecot-cvs mailing list