[dovecot-cvs] dovecot/src/lib-index mail-cache-fields.c,1.18,1.19

cras at dovecot.org cras at dovecot.org
Wed Feb 8 19:52:47 EET 2006


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

Modified Files:
	mail-cache-fields.c 
Log Message:
Don't register cache fields twice. Fixes "duplicate field in header" errors.



Index: mail-cache-fields.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-fields.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mail-cache-fields.c	30 Sep 2005 18:46:30 -0000	1.18
+++ mail-cache-fields.c	8 Feb 2006 17:52:45 -0000	1.19
@@ -17,7 +17,7 @@
 {
 	void *orig_key, *orig_value;
 	unsigned int new_idx;
-	size_t i;
+	unsigned int i, j;
 
 	new_idx = cache->fields_count;
 	for (i = 0; i < fields_count; i++) {
@@ -28,7 +28,17 @@
 			continue;
 		}
 
-		fields[i].idx = new_idx++;
+		/* check if the same header is being registered in the
+		   same field array */
+		for (j = 0; j < i; j++) {
+			if (strcasecmp(fields[i].name, fields[j].name) == 0) {
+				fields[i].idx = fields[j].idx;
+				break;
+			}
+		}
+
+		if (j == i)
+			fields[i].idx = new_idx++;
 	}
 
 	if (new_idx == cache->fields_count)



More information about the dovecot-cvs mailing list