bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#227652: gettext: msginit segfaults if input file has no header.


From: Bruno Haible
Subject: Re: Bug#227652: gettext: msginit segfaults if input file has no header. (fwd)
Date: Wed, 14 Jan 2004 13:40:44 +0100
User-agent: KMail/1.5

Josep Puigdemont wrote:
> If I try to initialize the metainformation with msgint of a message catalog
> (po file) that has no header it will produce a segmentation fault.
> The complete command line I used, including its output, is this:
>
> $ msginit -i original.pot -l ca -o pa.po
...
> Segmentation fault
> $
>
> The file original.pot begins like this:
> msgid ""
> msgstr ""
> "Project-Id-Version: \n"
> "PO-Revision-Date: YYYY-MM-DD HH:MM TZO DST\n"
> "Last-Translator: \n"
> "Language-Team: <address@hidden>\n"
> "MIME-Version: 1.0\n"
> "Content-Type: text/plain; charset=ISO-8859-1\n"
> "Content-Transfer-Encoding: 8-bit\n"

Thanks for the report. The appended patch fixes it.

Bruno


*** gettext-tools/src/msginit.c 14 Jan 2004 12:06:03 -0000      1.18
--- gettext-tools/src/msginit.c 14 Jan 2004 12:40:21 -0000
***************
*** 1655,1663 ****
        {
          message_ty *header_mp = NULL;
          char *header;
-         const char *subst[4][2];
-         const char *id;
-         time_t now;
  
          /* Search the header entry.  */
          for (j = 0; j < mlp->nitems; j++)
--- 1655,1660 ----
***************
*** 1700,1716 ****
          header_mp->msgstr_len = strlen (header) + 1;
  
          /* Update the comments in the header entry.  */
!         id = project_id ();
!         subst[0][0] = "SOME DESCRIPTIVE TITLE";
!         subst[0][1] = xasprintf (get_title (), id, id);
!         subst[1][0] = "PACKAGE";
!         subst[1][1] = id;
!         subst[2][0] = "FIRST AUTHOR <address@hidden>";
!         subst[2][1] = field_value[FIELD_LAST_TRANSLATOR];
!         subst[3][0] = "YEAR";
!         subst[3][1] =
!           xasprintf ("%d", (time (&now), (localtime (&now))->tm_year + 1900));
!         subst_string_list (header_mp->comment, SIZEOF (subst), subst);
  
          /* Finally remove the fuzzy attribute.  */
          header_mp->is_fuzzy = false;
--- 1697,1721 ----
          header_mp->msgstr_len = strlen (header) + 1;
  
          /* Update the comments in the header entry.  */
!         if (header_mp->comment != NULL)
!           {
!             const char *subst[4][2];
!             const char *id;
!             time_t now;
! 
!             id = project_id ();
!             subst[0][0] = "SOME DESCRIPTIVE TITLE";
!             subst[0][1] = xasprintf (get_title (), id, id);
!             subst[1][0] = "PACKAGE";
!             subst[1][1] = id;
!             subst[2][0] = "FIRST AUTHOR <address@hidden>";
!             subst[2][1] = field_value[FIELD_LAST_TRANSLATOR];
!             subst[3][0] = "YEAR";
!             subst[3][1] =
!               xasprintf ("%d",
!                          (time (&now), (localtime (&now))->tm_year + 1900));
!             subst_string_list (header_mp->comment, SIZEOF (subst), subst);
!           }
  
          /* Finally remove the fuzzy attribute.  */
          header_mp->is_fuzzy = false;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]