Currently it just silently overflowed the 16bit refcount, which caused
problems later.
#include <dirent.h>
#include <unistd.h>
+#define REBUILD_MAX_REFCOUNT 32768
+
struct mdbox_rebuild_msg {
struct mdbox_rebuild_msg *guid_hash_next;
GUID exists multiple times */
}
- if (rec != NULL) T_BEGIN {
+ if (rec != NULL &&
+ rec->refcount < REBUILD_MAX_REFCOUNT) T_BEGIN {
/* keep this message. add it to mailbox index. */
i_assert(map_uid != 0);
rec->refcount++;
mail_index_update_ext(ctx->prev_msg.trans, seq, mbox->guid_ext_id,
msg->guid_128, NULL);
+ i_assert(msg->refcount == 0);
msg->refcount++;
return 0;
}