From f98de965a08d1883a46ba5411922b54cc5125f14 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 7 Jul 2025 09:02:41 +0200 Subject: [PATCH] xgettext: Perl: Fix bug with comment lines longer than 1024 (regr. 2024-09-26). Reported by Alyssa Ross in . * gettext-tools/src/x-perl.c (phase2_getc): Move the sb_free call until after the savable_comment_add call. --- gettext-tools/src/x-perl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index d3aa50476..312fef371 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -558,7 +558,6 @@ phase2_getc (struct perl_extractor *xp) { int lineno; int c; - char *utf8_string; c = phase1_getc (xp); if (c == '#') @@ -587,12 +586,13 @@ phase2_getc (struct perl_extractor *xp) sb_xappend1 (&buffer, c); } /* Convert it to UTF-8. */ - utf8_string = - from_current_source_encoding (sb_xcontents_c (&buffer), lc_comment, + const char *contents = sb_xcontents_c (&buffer); + char *utf8_contents = + from_current_source_encoding (contents, lc_comment, logical_file_name, lineno); - sb_free (&buffer); /* Save it until we encounter the corresponding string. */ - savable_comment_add (utf8_string); + savable_comment_add (utf8_contents); + sb_free (&buffer); xp->last_comment_line = lineno; } return c; -- 2.47.3