dovecot-1.2: strmap: Make sure the records array is always zero-...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Sep 5 19:22:12 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/b8feb139cf92
changeset: 8155:b8feb139cf92
user: Timo Sirainen <tss at iki.fi>
date: Fri Sep 05 19:21:47 2008 +0300
description:
strmap: Make sure the records array is always zero-terminated.
diffstat:
2 files changed, 14 insertions(+)
src/lib-index/mail-index-strmap.c | 11 +++++++++++
src/lib-storage/index/index-thread.c | 3 +++
diffs (54 lines):
diff -r f15ce57d84d1 -r b8feb139cf92 src/lib-index/mail-index-strmap.c
--- a/src/lib-index/mail-index-strmap.c Fri Sep 05 12:40:28 2008 +0300
+++ b/src/lib-index/mail-index-strmap.c Fri Sep 05 19:21:47 2008 +0300
@@ -789,6 +789,14 @@ void mail_index_strmap_view_sync_add_uni
view->last_ref_index = ref_index;
}
+static void
+mail_index_strmap_zero_terminate(struct mail_index_strmap_view *view)
+{
+ /* zero-terminate the records array */
+ (void)array_append_space(&view->recs);
+ array_delete(&view->recs, array_count(&view->recs)-1, 1);
+}
+
static void mail_index_strmap_view_renumber(struct mail_index_strmap_view *view)
{
struct mail_index_strmap_read_context ctx;
@@ -835,6 +843,7 @@ static void mail_index_strmap_view_renum
i_assert(renumber_map[0] == 0);
array_delete(&view->recs, dest, i-dest);
array_delete(&view->recs_crc32, dest, i-dest);
+ mail_index_strmap_zero_terminate(view);
/* notify caller of the renumbering */
i_assert(str_idx <= view->next_str_idx);
@@ -1207,6 +1216,7 @@ void mail_index_strmap_view_sync_commit(
i_free(sync);
(void)mail_index_strmap_write(view);
+ mail_index_strmap_zero_terminate(view);
/* zero-terminate the records array */
(void)array_append_space(&view->recs);
@@ -1220,5 +1230,6 @@ void mail_index_strmap_view_sync_rollbac
*_sync = NULL;
mail_index_strmap_view_reset(sync->view);
+ mail_index_strmap_zero_terminate(sync->view);
i_free(sync);
}
diff -r f15ce57d84d1 -r b8feb139cf92 src/lib-storage/index/index-thread.c
--- a/src/lib-storage/index/index-thread.c Fri Sep 05 12:40:28 2008 +0300
+++ b/src/lib-storage/index/index-thread.c Fri Sep 05 19:21:47 2008 +0300
@@ -546,6 +546,9 @@ static int mail_thread_cache_sync_add(st
MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC);
msgid_map = array_get(tbox->msgid_map, &count);
+ /* we're relying on the array being zero-terminated (outside used
+ count - kind of kludgy) */
+ i_assert(msgid_map[count].uid == 0);
i = 0;
while (i < count && mailbox_search_next(search_ctx, mail) > 0) {
while (msgid_map[i].uid < mail->uid)
More information about the dovecot-cvs
mailing list