From: Bruno Haible Date: Wed, 14 Jan 2004 12:43:45 +0000 (+0000) Subject: Don't crash if the header entry has no comment. X-Git-Tag: v0.14~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d971c8b9306ee285c5b9f37c40e6fa584890e55d;p=thirdparty%2Fgettext.git Don't crash if the header entry has no comment. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index ef22b81d8..01cc61bad 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2004-01-14 Bruno Haible + + * msginit.c (fill_header): Avoid a NULL pointer access when the header + has no comment attached to it. + Reported by Josep Puigdemont . + 2004-01-09 Bruno Haible * msgattrib.c (main): Update year in --version output. diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c index 26637de99..7b46d4ba4 100644 --- a/gettext-tools/src/msginit.c +++ b/gettext-tools/src/msginit.c @@ -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 "; - 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 "; + 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;