From 4729b6937b582a029147ba51298f5c300c5b1891 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 14 Mar 2021 15:51:18 +0000 Subject: [PATCH 1/1] Avoid needless alloc for null header --- src/src/header.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/src/header.c b/src/src/header.c index cf7a81296..720446bff 100644 --- a/src/src/header.c +++ b/src/src/header.c @@ -97,12 +97,15 @@ header_add_backend(BOOL after, uschar *name, BOOL topnot, int type, header_line *h, *new = NULL; header_line **hptr; -uschar *p, *q; -uschar * buf = store_get(HEADER_ADD_BUFFER_SIZE, FALSE); -gstring gs = { .size = HEADER_ADD_BUFFER_SIZE, .ptr = 0, .s = buf }; +uschar * p, * q, * buf; +gstring gs; if (!header_last) return NULL; +gs.s = buf = store_get(HEADER_ADD_BUFFER_SIZE, FALSE); +gs.size = HEADER_ADD_BUFFER_SIZE; +gs.ptr = 0; + if (!string_vformat(&gs, SVFMT_REBUFFER, format, ap)) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "string too long in header_add: " "%.100s ...", string_from_gstring(&gs)); -- 2.30.2