]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Optimize replacing NULs in header
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 27 Aug 2018 12:06:44 +0000 (15:06 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:25:19 +0000 (11:25 +0300)
src/plugins/fts/fts-build-mail.c

index bd6729573a9b0943a4f3d5c340a88d31267008f0..3cb4ea657f3ba064669904702f463f86d71b58a8 100644 (file)
@@ -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);