# HG changeset patch # User Timo Sirainen # Date 1148978203 -10800 # Node ID ae0d876d98f59945e9a2c5df670f6e77bc600f36 # Parent 22b54c007b915c4e61f6cb70179fdef6c5c496f7 Memory leak fix for last update and some other cleanups diff -r 22b54c007b91 -r ae0d876d98f5 src/lib-index/mail-index-sync-update.c --- a/src/lib-index/mail-index-sync-update.c Tue May 30 11:36:11 2006 +0300 +++ b/src/lib-index/mail-index-sync-update.c Tue May 30 11:36:43 2006 +0300 @@ -17,18 +17,22 @@ { struct mail_index_view *view = ctx->view; + i_assert(view->map != map); + /* if map still exists after this, it's only in views. */ view->map->write_to_disk = FALSE; mail_index_unmap(view->index, &view->map); view->map = map; - view->map->refcount++; if ((ctx->type & (MAIL_INDEX_SYNC_HANDLER_FILE | MAIL_INDEX_SYNC_HANDLER_HEAD)) != 0) { + i_assert(view->index->map != map); + mail_index_unmap(view->index, &view->index->map); view->index->map = map; view->index->hdr = &map->hdr; + map->refcount++; if (ctx->type == MAIL_INDEX_SYNC_HANDLER_FILE) { map->write_to_disk = TRUE; @@ -770,6 +774,8 @@ map->hdr.log_file_seq = seq; map->hdr.log_file_ext_offset = offset; + i_assert(map->hdr_copy_buf->used <= map->hdr.header_size); + if (first_append_uid != 0) mail_index_update_day_headers(&map->hdr, first_append_uid);