some variables were not initialize, correct a bug in expunging.
Showing
5 changed files
with
22 additions
and
13 deletions
... | @@ -127,7 +127,7 @@ int message_save_attachment(message_t msg, const char *filename, void **data) | ... | @@ -127,7 +127,7 @@ int message_save_attachment(message_t msg, const char *filename, void **data) |
127 | stream_t stream; | 127 | stream_t stream; |
128 | header_t hdr; | 128 | header_t hdr; |
129 | struct _msg_info *info = NULL; | 129 | struct _msg_info *info = NULL; |
130 | int ret; | 130 | int ret = 0; |
131 | size_t size; | 131 | size_t size; |
132 | char *content_encoding; | 132 | char *content_encoding; |
133 | 133 | ... | ... |
... | @@ -159,7 +159,7 @@ int | ... | @@ -159,7 +159,7 @@ int |
159 | bio_write (bio_t bio, const char *ptr, size_t n, size_t *pnwriten) | 159 | bio_write (bio_t bio, const char *ptr, size_t n, size_t *pnwriten) |
160 | { | 160 | { |
161 | int nleft; | 161 | int nleft; |
162 | int err; | 162 | int err = 0; |
163 | size_t nwriten = 0; | 163 | size_t nwriten = 0; |
164 | size_t total = 0; | 164 | size_t total = 0; |
165 | 165 | ... | ... |
... | @@ -121,7 +121,7 @@ _file_write (stream_t stream, const char *iptr, size_t isize, | ... | @@ -121,7 +121,7 @@ _file_write (stream_t stream, const char *iptr, size_t isize, |
121 | { | 121 | { |
122 | struct _file_stream *fs = stream_get_owner (stream); | 122 | struct _file_stream *fs = stream_get_owner (stream); |
123 | size_t n; | 123 | size_t n; |
124 | int err; | 124 | int err = 0; |
125 | 125 | ||
126 | if (fs == NULL) | 126 | if (fs == NULL) |
127 | return EINVAL; | 127 | return EINVAL; | ... | ... |
... | @@ -40,7 +40,7 @@ mailer_create (mailer_t *pmailer, const char *name, int id) | ... | @@ -40,7 +40,7 @@ mailer_create (mailer_t *pmailer, const char *name, int id) |
40 | mailer_entry_t entry = NULL; | 40 | mailer_entry_t entry = NULL; |
41 | list_t list = NULL; | 41 | list_t list = NULL; |
42 | iterator_t iterator; | 42 | iterator_t iterator; |
43 | int found; | 43 | int found = 0; |
44 | 44 | ||
45 | (void)id; | 45 | (void)id; |
46 | if (pmailer == NULL) | 46 | if (pmailer == NULL) | ... | ... |
... | @@ -749,15 +749,24 @@ mbox_expunge (mailbox_t mailbox) | ... | @@ -749,15 +749,24 @@ mbox_expunge (mailbox_t mailbox) |
749 | mum = mud->umessages[j]; | 749 | mum = mud->umessages[j]; |
750 | if (mum->new_flags && ATTRIBUTE_IS_DELETED (mum->new_flags)) | 750 | if (mum->new_flags && ATTRIBUTE_IS_DELETED (mum->new_flags)) |
751 | { | 751 | { |
752 | memmove (mud->umessages + j, mud->umessages + j + 1, | 752 | if ((j + 1) >= mud->messages_count) |
753 | (dlast - dirty) * sizeof (mum)); | 753 | { |
754 | mum->header_from = mum->header_from_end = 0; | 754 | /* Move all the pointers up. So the message pointer |
755 | mum->header_status = mum->header_status_end = 0; | 755 | part of mum will be at the right position. */ |
756 | mum->body = mum->body_end = 0; | 756 | memmove (mud->umessages + j, mud->umessages + j + 1, |
757 | mum->header_lines = mum->body_lines = 0; | 757 | (dlast - dirty) * sizeof (mum)); |
758 | mud->umessages[dlast] = mum; | 758 | mum->header_from = mum->header_from_end = 0; |
759 | dlast--; | 759 | mum->header_status = mum->header_status_end = 0; |
760 | mum = mud->umessages[j]; | 760 | mum->body = mum->body_end = 0; |
761 | mum->header_lines = mum->body_lines = 0; | ||
762 | /* We are not free()ing the useless mum, but instead | ||
763 | we put it back in the pool, to be reuse. */ | ||
764 | mud->umessages[dlast] = mum; | ||
765 | dlast--; | ||
766 | /* Set mum to the new value after the memmove so it | ||
767 | gets cleared to. */ | ||
768 | mum = mud->umessages[j]; | ||
769 | } | ||
761 | } | 770 | } |
762 | mum->header_from = mum->header_from_end = 0; | 771 | mum->header_from = mum->header_from_end = 0; |
763 | mum->header_status = mum->header_status_end = 0; | 772 | mum->header_status = mum->header_status_end = 0; | ... | ... |
-
Please register or sign in to post a comment