From e90068a9046ccaf0bed82fd180b4748edbd5659a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 31 Dec 2006 18:18:23 -0800 Subject: [PATCH] i18n: do not leak 'encoding' header even when we cheat the conversion. We special case the case where encoding recorded in the commit and the output encoding are the same and do not call iconv(). But we should drop 'encoding' header for this case as well for consistency. Signed-off-by: Junio C Hamano --- commit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/commit.c b/commit.c index afdf27eec..544e42629 100644 --- a/commit.c +++ b/commit.c @@ -679,11 +679,13 @@ static char *logmsg_reencode(const struct commit *commit) else if (!*output_encoding) return NULL; encoding = get_header(commit, "encoding"); - if (!encoding || !strcmp(encoding, output_encoding)) { - free(encoding); + if (!encoding) return NULL; - } - out = reencode_string(commit->buffer, output_encoding, encoding); + if (!strcmp(encoding, output_encoding)) + out = strdup(commit->buffer); + else + out = reencode_string(commit->buffer, + output_encoding, encoding); if (out) out = replace_encoding_header(out, output_encoding); -- 2.26.2