summary refs log tree commit diff
path: root/archive.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--archive.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/archive.c b/archive.c
index 756f822..86f0687 100644
--- a/archive.c
+++ b/archive.c
@@ -218,6 +218,7 @@ examine:;
 
 concat:;
 	enum Atom concat = atom("concat");
+	struct List envelopeItems = {0};
 	struct Envelope *envelopes = calloc(threads.len, sizeof(*envelopes));
 	if (!envelopes) err(EX_OSERR, "calloc");
 	concatFetch(imap.w, concat, threads);
@@ -227,12 +228,21 @@ concat:;
 		// Prevent freeing data in envelopes with resp:
 		struct Data items = dataTake(&resp.data.ptr[0]);
 		concatData(threads, envelopes, dataCheck(items, List).list);
+		listPush(&envelopeItems, items);
 	}
 	respFree(resp);
 
 	concatThreads(threads, envelopes);
 	concatIndex(threads, envelopes);
 	uidWrite("UIDNEXT", uidNext);
+
+	for (size_t i = 0; i < threads.len; ++i) {
+		envelopeFree(envelopes[i]);
+	}
+	free(envelopes);
+	listFree(envelopeItems);
+	listFree(threads);
+
 	if (!idle) goto logout;
 
 idle: