From b2d0ca6db3c32de21f428065df0608bcf8143a85 Mon Sep 17 00:00:00 2001 From: miximka Date: Fri, 9 Jun 2023 09:53:47 +0200 Subject: [PATCH] Avoid double-free of the memory allocated inside charconv method for result parameter when it fails to convert charsets --- src/data-types/charconv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data-types/charconv.c b/src/data-types/charconv.c index 161f493f..596e09e8 100644 --- a/src/data-types/charconv.c +++ b/src/data-types/charconv.c @@ -173,6 +173,7 @@ int charconv(const char * tocode, const char * fromcode, res = (*extended_charconv)( tocode, fromcode, str, length, *result, &result_length); if (res != MAIL_CHARCONV_NO_ERROR) { free( *result); + *result = NULL; } else { out = realloc( *result, result_length + 1); if (out != NULL) *result = out;