cyrusimap/cyrus-imapd

Memory leak in index_copy()

Closed this issue · 0 comments

index_copy() contains:

ptrarray_t *msgrecs = ptrarray_new();
is_same_user = mboxname_same_userid(index_mboxname(state), name);
if (is_same_user < 0)
    return is_same_user;
r = index_check(state, usinguid, usinguid);
if (r) return r;

msgrecs is leaked on any of the returns.

Please consider generally defining and declaring variables just before they are needed, instead of the beginnig of each function. This simple procedure would avoid this and other memory leaks.