This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gettext loaded_domain initialization



In 'ls' I got a crash at the first access to domain->conv_tab[act] because
domain->conv_tab was uninitialized garbage. Here is a patch that ensures to
initialize domain->conv_tab and two other members of the same structure,
which also could be uninitialized in some circumstances.


2000-05-01  Bruno Haible  <clisp.cons.org>

	* intl/loadmsgcat.c (_nl_load_domain): Initialize domain->conv_tab.
	Initialize domain->plural and domain->nplurals even if there is no
	nullentry.

*** gettext-work.orig/intl/loadmsgcat.c	Sat Apr 29 09:02:16 2000
--- gettext-workahead/intl/loadmsgcat.c	Mon May  1 17:54:45 2000
***************
*** 254,267 ****
    domain->conv = (iconv_t) -1;
  # endif
  #endif
    nullentry = _nl_find_msg (domain_file, "", 0);
    if (nullentry != NULL)
      {
        const char *charsetstr;
-       const char *plural;
-       const char *nplurals;
  
- #if defined _LIBC || HAVE_ICONV
        charsetstr = strstr (nullentry, "charset=");
        if (charsetstr != NULL)
  	{
--- 263,275 ----
    domain->conv = (iconv_t) -1;
  # endif
  #endif
+   domain->conv_tab = NULL;
    nullentry = _nl_find_msg (domain_file, "", 0);
    if (nullentry != NULL)
      {
+ #if defined _LIBC || HAVE_ICONV
        const char *charsetstr;
  
        charsetstr = strstr (nullentry, "charset=");
        if (charsetstr != NULL)
  	{
***************
*** 299,317 ****
  # endif
  	}
  #endif /* _LIBC || HAVE_ICONV */
  
-       /* Also look for a plural specification.  */
        plural = strstr (nullentry, "plural=");
        nplurals = strstr (nullentry, "nplurals=");
        if (plural == NULL || nplurals == NULL)
! 	{
! 	  /* By default we are using the Germanic form: singular form only
! 	     for `one', the plural form otherwise.  Yes, this is also what
! 	     English is using since English is a Germanic language.  */
! 	no_plural:
! 	  domain->plural = &germanic_plural;
! 	  domain->nplurals = 2;
! 	}
        else
  	{
  	  /* First get the number.  */
--- 328,345 ----
  # endif
  	}
  #endif /* _LIBC || HAVE_ICONV */
+     }
+ 
+   /* Also look for a plural specification.  */
+   if (nullentry != NULL)
+     {
+       const char *plural;
+       const char *nplurals;
  
        plural = strstr (nullentry, "plural=");
        nplurals = strstr (nullentry, "nplurals=");
        if (plural == NULL || nplurals == NULL)
! 	goto no_plural;
        else
  	{
  	  /* First get the number.  */
***************
*** 335,340 ****
--- 363,377 ----
  	    goto no_plural;
  	  domain->plural = args.res;
  	}
+     }
+   else
+     {
+       /* By default we are using the Germanic form: singular form only
+          for `one', the plural form otherwise.  Yes, this is also what
+          English is using since English is a Germanic language.  */
+     no_plural:
+       domain->plural = &germanic_plural;
+       domain->nplurals = 2;
      }
  }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]