changeset 3698:b358ee31b5ea HEAD

Set mail_ctx=NULL always after doing something for the last mail, even if we didn't rewrite its headers. Otherwise internal state breaks and we'll crash.
author Timo Sirainen <tss@iki.fi>
date Fri, 28 Oct 2005 17:01:28 +0300
parents 0353f93f57bc
children 5b7087ba4118
files src/lib-storage/index/mbox/mbox-sync-rewrite.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Fri Oct 28 16:38:36 2005 +0300
+++ b/src/lib-storage/index/mbox/mbox-sync-rewrite.c	Fri Oct 28 17:01:28 2005 +0300
@@ -375,6 +375,7 @@
 				    expunged_space);
 		mail_ctx = &new_mail_ctx;
 	} else {
+		i_assert(seq == mail_ctx->seq);
 		if (mail_ctx->mail.space < 0)
 			mail_ctx->mail.space = 0;
 	}
@@ -500,7 +501,6 @@
 				ret = -1;
 				break;
 			}
-			mail_ctx = NULL;
 			move_diff -= next_move_diff + mails[idx].space;
 		} else {
 			/* this mail provides more space. just move it forward
@@ -534,6 +534,7 @@
 			}
 			mails[idx].offset += move_diff;
 		}
+		mail_ctx = NULL;
 
 		i_assert(move_diff >= 0 || idx == first_nonexpunged_idx);
 		i_assert(next_end_offset <= end_offset);