Skip to content

Commit

Permalink
Merge pull request cyrusimap#4901 from cyrusimap/jmap_mail_query_fix_…
Browse files Browse the repository at this point in the history
…valgrind_error_20240429

message.c: do not leak memory for split conversations
  • Loading branch information
rsto committed Apr 29, 2024
2 parents e2f6303 + f91e3b4 commit 9011128
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions imap/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -5632,19 +5632,27 @@ EXPORTED int message_extract_cids(message_t *msg,
int r = extract_convdata(cstate, msg, &msgidlist, cids, &msubj);
strarray_fini(&msgidlist);
free(msubj);

struct buf annotkey = BUF_INITIALIZER;
struct buf annotval = BUF_INITIALIZER;
size_t i;

for (i = 0; i < arrayu64_size(cids); i++) {
conversation_id_t newcid = 0;
struct buf annotkey = BUF_INITIALIZER;
struct buf annotval = BUF_INITIALIZER;
buf_reset(&annotkey);
buf_reset(&annotval);
buf_printf(&annotkey, "%snewcid/%016llx", IMAP_ANNOT_NS, (conversation_id_t) arrayu64_nth(cids, i));
annotatemore_lookup(cstate->annotmboxname, buf_cstring(&annotkey), "", &annotval);
if (annotval.len == 16) {
if (buf_len(&annotval) == 16) {
const char *p = buf_cstring(&annotval);
/* we have a new canonical CID */
parsehex(p, &p, 16, &newcid);
}
if (newcid) arrayu64_set(cids, i, newcid);
}

buf_free(&annotkey);
buf_free(&annotval);

return r;
}

0 comments on commit 9011128

Please sign in to comment.