]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix a small memory leak.
authorBruno Haible <bruno@clisp.org>
Mon, 28 Jul 2025 14:01:40 +0000 (16:01 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 28 Jul 2025 14:24:37 +0000 (16:24 +0200)
Reported by Coverity.

* gettext-tools/src/format-python.c (format_parse): Free name before returning.

gettext-tools/src/format-python.c

index 78b3154309d9cdee8af83e8981cc1d81d26e67dc..41ce96b3e5234361d53a32a672b9bb93bb0706b6 100644 (file)
@@ -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;