]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Don't crash if the header entry has no comment.
authorBruno Haible <bruno@clisp.org>
Wed, 14 Jan 2004 12:43:45 +0000 (12:43 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:37 +0000 (12:11 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/msginit.c

index ef22b81d8978afd4ebf01bcfc505a677a1b60edd..01cc61bad6856fa0773bde09eb2600110f42e9c2 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-14  Bruno Haible  <bruno@clisp.org>
+
+       * msginit.c (fill_header): Avoid a NULL pointer access when the header
+       has no comment attached to it.
+       Reported by Josep Puigdemont <baldrick@terra.es>.
+
 2004-01-09  Bruno Haible  <bruno@clisp.org>
 
        * msgattrib.c (main): Update year in --version output.
index 26637de99c119e3fa62ad211b36751640156479c..7b46d4ba4daa256587e28ade1756916a6cf158d8 100644 (file)
@@ -1655,9 +1655,6 @@ fill_header (msgdomain_list_ty *mdlp)
        {
          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++)
@@ -1700,17 +1697,25 @@ fill_header (msgdomain_list_ty *mdlp)
          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 <EMAIL@ADDRESS>";
-         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);
+         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 <EMAIL@ADDRESS>";
+             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;