@matheusbsbs / matheus-bagliano / commits / e90068a904
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Dec 31, 2006 at 18:18 UTC e90068a9046ccaf0bed82fd180b4748edbd5659a
1 file changed +6 -4
commit.c
+6 -4
@@ -679,11 +679,13 @@ static char *logmsg_reencode(const struct commit *commit)
679 else if (!*output_encoding)
680 return NULL;
681 encoding = get_header(commit, "encoding");
682 - if (!encoding || !strcmp(encoding, output_encoding)) {
683 - free(encoding);
682 + if (!encoding)
683 return NULL;
685 - }
686 - out = reencode_string(commit->buffer, output_encoding, encoding);
684 + if (!strcmp(encoding, output_encoding))
685 + out = strdup(commit->buffer);
686 + else
687 + out = reencode_string(commit->buffer,
688 + output_encoding, encoding);
689 if (out)
690 out = replace_encoding_header(out, output_encoding);
691