From f9e3329954a4f7d3fc9dd6757226bd6d93a00e22 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 28 Jul 2025 16:01:40 +0200 Subject: [PATCH] Fix a small memory leak. Reported by Coverity. * gettext-tools/src/format-python.c (format_parse): Free name before returning. --- gettext-tools/src/format-python.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gettext-tools/src/format-python.c b/gettext-tools/src/format-python.c index 78b315430..41ce96b3e 100644 --- a/gettext-tools/src/format-python.c +++ b/gettext-tools/src/format-python.c @@ -191,6 +191,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Named and unnamed specifications are exclusive. */ if (spec.named_arg_count > 0) { + free (name); *invalid_reason = INVALID_MIXES_NAMED_UNNAMED (); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; @@ -220,6 +221,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Named and unnamed specifications are exclusive. */ if (spec.named_arg_count > 0) { + free (name); *invalid_reason = INVALID_MIXES_NAMED_UNNAMED (); FDI_SET (format - 1, FMTDIR_ERROR); goto bad_format; @@ -267,6 +269,7 @@ format_parse (const char *format, bool translated, char *fdi, type = FAT_FLOAT; break; default: + free (name); if (*format == '\0') { *invalid_reason = INVALID_UNTERMINATED_DIRECTIVE (); @@ -288,6 +291,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Named and unnamed specifications are exclusive. */ if (spec.unnamed_arg_count > 0) { + free (name); *invalid_reason = INVALID_MIXES_NAMED_UNNAMED (); FDI_SET (format, FMTDIR_ERROR); goto bad_format; @@ -309,6 +313,7 @@ format_parse (const char *format, bool translated, char *fdi, /* Named and unnamed specifications are exclusive. */ if (spec.named_arg_count > 0) { + free (name); *invalid_reason = INVALID_MIXES_NAMED_UNNAMED (); FDI_SET (format, FMTDIR_ERROR); goto bad_format; -- 2.47.3