From: Timo Sirainen Date: Mon, 27 Aug 2018 12:06:44 +0000 (+0300) Subject: fts: Optimize replacing NULs in header X-Git-Tag: 2.3.4~229 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7057aa9de15433d6ebb5a741ea46584ee2d2fd39;p=thirdparty%2Fdovecot%2Fcore.git fts: Optimize replacing NULs in header --- diff --git a/src/plugins/fts/fts-build-mail.c b/src/plugins/fts/fts-build-mail.c index bd6729573a..3cb4ea657f 100644 --- a/src/plugins/fts/fts-build-mail.c +++ b/src/plugins/fts/fts-build-mail.c @@ -93,13 +93,11 @@ fts_build_unstructured_header(struct fts_mail_build_context *ctx, for (i = 0; i < hdr->full_value_len; i++) { if (hdr->full_value[i] == '\0') { if (buf == NULL) { - buf = i_malloc(hdr->full_value_len); - memcpy(buf, hdr->full_value, i); + buf = i_memdup(hdr->full_value, + hdr->full_value_len); data = buf; } buf[i] = ' '; - } else if (buf != NULL) { - buf[i] = hdr->full_value[i]; } } ret = fts_build_data(ctx, data, hdr->full_value_len, TRUE);