From 680a8623380b0da89b029d4269d38c541726a39b Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 3 Jan 2013 14:18:38 +0900 Subject: [PATCH] Fix memory leak. --- gettext-tools/src/ChangeLog | 4 ++++ gettext-tools/src/xgettext.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 2ab9c530a..2faff73ad 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,7 @@ +2013-01-03 Daiki Ueno + + * xgettext.c (construct_header): Fix memory leak. + 2012-12-25 Daiki Ueno * gettext-0.18.2 released. diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index eb3271f52..90184b7f7 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -3000,6 +3000,7 @@ construct_header () char *timestring; message_ty *mp; char *msgstr; + char *comment; static lex_pos_ty pos = { __FILE__, __LINE__ }; if (package_name != NULL) @@ -3043,18 +3044,20 @@ Content-Transfer-Encoding: 8bit\n", mp = message_alloc (NULL, "", NULL, msgstr, strlen (msgstr) + 1, &pos); - message_comment_append (mp, - copyright_holder[0] != '\0' - ? xasprintf ("\ + if (copyright_holder[0] != '\0') + comment = xasprintf ("\ SOME DESCRIPTIVE TITLE.\n\ Copyright (C) YEAR %s\n\ This file is distributed under the same license as the PACKAGE package.\n\ FIRST AUTHOR , YEAR.\n", - copyright_holder) - : "\ + copyright_holder); + else + comment = xstrdup ("\ SOME DESCRIPTIVE TITLE.\n\ This file is put in the public domain.\n\ FIRST AUTHOR , YEAR.\n"); + message_comment_append (mp, comment); + free (comment); mp->is_fuzzy = true; -- 2.47.2