Mercurial > dovecot > core-2.2
changeset 18999:d5cddaa5ca92
dsync: Fixed memory leaks when importing attributes whose values were in istreams.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 24 Aug 2015 14:59:52 +0300 |
parents | 196c76bdc11a |
children | de8af4d857d3 |
files | src/doveadm/dsync/dsync-mailbox-import.c |
diffstat | 1 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/dsync/dsync-mailbox-import.c Mon Aug 24 14:40:11 2015 +0300 +++ b/src/doveadm/dsync/dsync-mailbox-import.c Mon Aug 24 14:59:52 2015 +0300 @@ -402,18 +402,15 @@ static int dsync_mailbox_import_attribute_real(struct dsync_mailbox_importer *importer, const struct dsync_mailbox_attribute *attr, + const struct dsync_mailbox_attribute *local_attr, const char **result_r) { - struct dsync_mailbox_attribute *local_attr; struct mail_attribute_value value; int cmp; bool ignore = FALSE; i_assert(DSYNC_ATTR_HAS_VALUE(attr) || attr->deleted); - if (dsync_mailbox_import_lookup_attr(importer, attr->type, - attr->key, &local_attr) < 0) - return -1; if (attr->deleted && (local_attr == NULL || !DSYNC_ATTR_HAS_VALUE(local_attr))) { /* attribute doesn't exist on either side -> ignore */ @@ -474,11 +471,8 @@ *result_r = "Value changed, but unknown which is newer - picking remote"; } } - if (ignore) { - if (local_attr->value_stream != NULL) - i_stream_unref(&local_attr->value_stream); + if (ignore) return 0; - } memset(&value, 0, sizeof(value)); value.value = attr->value; @@ -492,18 +486,25 @@ /* the attributes aren't vital, don't fail everything just because of them. */ } - if (local_attr != NULL && local_attr->value_stream != NULL) - i_stream_unref(&local_attr->value_stream); return 0; } int dsync_mailbox_import_attribute(struct dsync_mailbox_importer *importer, const struct dsync_mailbox_attribute *attr) { + struct dsync_mailbox_attribute *local_attr; const char *result; int ret; - ret = dsync_mailbox_import_attribute_real(importer, attr, &result); + if (dsync_mailbox_import_lookup_attr(importer, attr->type, + attr->key, &local_attr) < 0) + ret = -1; + else { + ret = dsync_mailbox_import_attribute_real(importer, attr, + local_attr, &result); + if (local_attr != NULL && local_attr->value_stream != NULL) + i_stream_unref(&local_attr->value_stream); + } imp_debug(importer, "Import attribute %s: %s", attr->key, ret < 0 ? "failed" : result); return ret;