]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - locale.c
Imported from ../bash-2.05.tar.gz.
[thirdparty/bash.git] / locale.c
index fba962cc3a31a59cae5a46748ec840c2b84f9d8f..39ded78da9e869066364655c5077836f0bfd9c6e 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -234,12 +234,10 @@ localetrans (string, len, lenp)
   if (string == 0 || *string == 0)
     {
       if (lenp)
-        *lenp = 0;
+       *lenp = 0;
       return ((char *)NULL);
     }
 
-  t = xmalloc (len + 1);
-
   locale = get_locale_var ("LC_MESSAGES");
 
   /* If we don't have setlocale() or the current locale is `C' or `POSIX',
@@ -250,6 +248,7 @@ localetrans (string, len, lenp)
       (locale[0] == 'C' && locale[1] == '\0') || STREQ (locale, "POSIX"))
 #endif
     {
+      t = xmalloc (len + 1);
       strcpy (t, string);
       if (lenp)
        *lenp = len;
@@ -261,13 +260,13 @@ localetrans (string, len, lenp)
   translated = gettext (string);
   if (translated == string)    /* gettext returns its argument if untranslatable */
     {
+      t = xmalloc (len + 1);
       strcpy (t, string);
       if (lenp)
        *lenp = len;
     }
   else
     {
-      free (t);
       tlen = strlen (translated);
       t = xmalloc (tlen + 1);
       strcpy (t, translated);