Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8149:17cec811c5fd HEAD
Thread indexes: Crashfix.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 01 Sep 2008 16:10:27 +0300 |
parents | 920c1ca3a8db |
children | 7b5120f7f732 |
files | src/lib-storage/index/index-thread-links.c |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-thread-links.c Mon Sep 01 15:31:20 2008 +0300 +++ b/src/lib-storage/index/index-thread-links.c Mon Sep 01 16:10:27 2008 +0300 @@ -50,8 +50,16 @@ i_assert(parent_idx < cache->first_invalid_msgid_str_idx); - parent = array_idx_modifiable(&cache->thread_nodes, parent_idx); - child = array_idx_modifiable(&cache->thread_nodes, child_idx); + /* either child_idx or parent_idx may cause thread_nodes array to + grow. in such situation the other pointer may become invalid if + we don't get the pointers in correct order. */ + if (child_idx < parent_idx) { + parent = array_idx_modifiable(&cache->thread_nodes, parent_idx); + child = array_idx_modifiable(&cache->thread_nodes, child_idx); + } else { + child = array_idx_modifiable(&cache->thread_nodes, child_idx); + parent = array_idx_modifiable(&cache->thread_nodes, parent_idx); + } child->parent_link_refcount++; if (thread_node_has_ancestor(cache, parent, child)) {