about summary refs log tree commit diff
path: root/locale/setlocale.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-12-01 00:43:32 +0000
committerUlrich Drepper <drepper@redhat.com>2000-12-01 00:43:32 +0000
commit411adb106872a8c52e26ca5f7049d5ec0a4a99dd (patch)
tree0b4e68c6bb175004f36e80049cdd14e9680d8cf5 /locale/setlocale.c
parent9a0fe6a8124692b9b09489f64717af94d1ffac13 (diff)
downloadglibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.tar.gz
glibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.tar.xz
glibc-411adb106872a8c52e26ca5f7049d5ec0a4a99dd.zip
Update.
2000-11-29  H.J. Lu  <hjl@gnu.org>

	* stdio-common/vfscanf.c (ORIENT): Swap the COMPILE_WSCANF case.

2000-11-30  Jakub Jelinek  <jakub@redhat.com>

	* locale/setlocale.c (setname): Free for all categories, not just
	LC_ALL.
	(setlocale): Store a copy of string passed by user, not the string
	itself.

	* sysdeps/unix/sysv/linux/hppa/brk.c (__brk): Remove unused variable.
Diffstat (limited to 'locale/setlocale.c')
-rw-r--r--locale/setlocale.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/locale/setlocale.c b/locale/setlocale.c
index 3598eceac4..c7848b9a5c 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -194,7 +194,7 @@ setname (int category, const char *name)
   if (_nl_current_names[category] == name)
     return;
 
-  if (category == LC_ALL && _nl_current_names[category] != _nl_C_name)
+  if (_nl_current_names[category] != _nl_C_name)
     free ((char *) _nl_current_names[category]);
 
   _nl_current_names[category] = name;
@@ -322,6 +322,14 @@ setlocale (int category, const char *locale)
 	       control over the usage.  So we mark it as un-deletable.  */
 	    if (newdata[category]->usage_count != UNDELETABLE)
 	      newdata[category]->usage_count = UNDELETABLE;
+
+	    /* Make a copy of locale name.  */
+	    if (newnames[category] != _nl_C_name)
+	      {
+		newnames[category] = strdup (newnames[category]);
+		if (newnames[category] == NULL)
+		  break;
+	      }
 	  }
 
       /* Create new composite name.  */
@@ -342,6 +350,10 @@ setlocale (int category, const char *locale)
 	     functions know about this.  */
 	  ++_nl_msg_cat_cntr;
 	}
+      else
+	for (++category; category < __LC_LAST; ++category)
+	  if (category != LC_ALL && newnames[category] != _nl_C_name)
+	    free ((char *) newnames[category]);
 
       /* Critical section left.  */
       __libc_lock_unlock (__libc_setlocale_lock);
@@ -376,10 +388,21 @@ setlocale (int category, const char *locale)
 	    newdata->usage_count = UNDELETABLE;
 	}
 
+      /* Make a copy of locale name.  */
+      if (newname[0] != _nl_C_name)
+	{
+	  newname[0] = strdup (newname[0]);
+	  if (newname[0] == NULL)
+	    goto abort_single;
+	}
+
       /* Create new composite name.  */
       composite = new_composite_name (category, newname);
       if (composite == NULL)
 	{
+	  if (newname[0] != _nl_C_name)
+	    free ((char *) newname[0]);
+
 	  /* Say that we don't have any data loaded.  */
 	abort_single:
 	  newname[0] = NULL;