changeset 2871:d72a03773b2f HEAD

crashfix
author Timo Sirainen <tss@iki.fi>
date Mon, 08 Nov 2004 04:31:40 +0200
parents 2f00acfc6bc2
children c0e2a38b7647
files src/lib-index/mail-index-sync-update.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-update.c	Mon Nov 08 04:12:55 2004 +0200
+++ b/src/lib-index/mail-index-sync-update.c	Mon Nov 08 04:31:40 2004 +0200
@@ -477,6 +477,11 @@
 	new_map = mail_index_map_to_memory(map, offset);
 	map->records_count = old_records_count;
 
+	if (old_size > ext[ext_id].record_size) {
+		/* we are shrinking the record */
+		old_size = ext[ext_id].record_size;
+	}
+
 	/* now copy the records to new mapping */
 	src = map->records;
 	offset = 0;
@@ -494,6 +499,12 @@
 		offset += new_map->hdr->record_size;
 	}
 
+	if (ext_id == size-1 && ext[ext_id].record_size != old_size) {
+		/* we didn't fully write the last record */
+		buffer_append_zero(new_map->buffer,
+				   ext[ext_id].record_size - old_size);
+	}
+
 	new_map->records = buffer_get_modifyable_data(new_map->buffer, NULL);
 	new_map->records_count = old_records_count;