]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 31 Dec 2003 22:46:53 +0000 (22:46 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 31 Dec 2003 22:46:53 +0000 (22:46 +0000)
* locale/setlocale.c (setlocale): Avoid duplicating locale names
if we can reuse old strings.

ChangeLog
linuxthreads/ChangeLog
linuxthreads/attr.c
locale/setlocale.c

index bb64d54912b903d6cdae541a587db72a0f6d9b28..158dc1a4a60e8bdc0feacb1b8f53658bf8f7cd50 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-12-31  Ulrich Drepper  <drepper@redhat.com>
 
+       * locale/setlocale.c (setlocale): Avoid duplicating locale names
+       if we can reuse old strings.
+
        * inet/rcmd.c: Provide better error message in case of unknown
        host.  Remove USE_IN_LIBIO.
 
index f0f299ac1d7cb43beec16f55e350d637cb230f84..147811f141f1ffe791bc622207bf5c3ce03a06b2 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-31  Ulrich Drepper  <drepper@redhat.com>
+
+       * attr.c (pthread_getattr_np): Make sure stack info returned for
+       main thread does not overlap with any other VMA.
+       Patch by Jakub Jelinek.
+
 2003-12-29  Jakub Jelinek  <jakub@redhat.com>
 
        * sysdeps/ia64/tls.h: Include dl-sysdep.h.
index 80f5249d3657e25a25b7d4037ba5ac713be67cfa..a88fdb96c59579e6eb14c09208d11b5d3481df01 100644 (file)
@@ -441,6 +441,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 
          char *line = NULL;
          size_t linelen = 0;
+         uintptr_t last_to = 0;
 
          while (! feof_unlocked (fp))
            {
@@ -449,8 +450,9 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 
              uintptr_t from;
              uintptr_t to;
-             if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) == 2
-                 && from <= (uintptr_t) __libc_stack_end
+             if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+               continue;
+             if (from <= (uintptr_t) __libc_stack_end
                  && (uintptr_t) __libc_stack_end < to)
                {
                  /* Found the entry.  Now we have the info we need.  */
@@ -461,16 +463,17 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 #else
                  attr->__stackaddr = (void *) to;
 
-                 /* The limit might be too high.  This is a bogus
-                    situation but try to avoid making it worse.  */
-                 if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr)
-                   attr->__stacksize = (size_t) attr->__stackaddr;
+                 /* The limit might be too high.  */
+                 if ((size_t) attr->__stacksize
+                     > (size_t) attr->__stackaddr - last_to)
+                   attr->__stacksize = (size_t) attr->__stackaddr - last_to;
 #endif
 
                  /* We succeed and no need to look further.  */
                  ret = 0;
                  break;
                }
+             last_to = to;
            }
 
          fclose (fp);
index 9f6e96439b1b3f2e7d1d8b83299f656dc3b5df6e..d012d0265f8b718ce4697a9a60a4163f02019d02 100644 (file)
@@ -322,17 +322,25 @@ setlocale (int category, const char *locale)
                break;
              }
 
-           /* We must not simply free a global locale since we have no
-              control over the usage.  So we mark it as un-deletable.  */
+           /* We must not simply free a global locale since we have
+              no control over the usage.  So we mark it as
+              un-deletable.  And yes, the 'if' is needed, the data
+              might be in read-only memory.  */
            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;
+               if (strcmp (newnames[category],
+                           _nl_global_locale.__names[category]) == 0)
+                 newnames[category] = _nl_global_locale.__names[category];
+               else
+                 {
+                   newnames[category] = __strdup (newnames[category]);
+                   if (newnames[category] == NULL)
+                     break;
+                 }
              }
          }
 
@@ -356,7 +364,8 @@ setlocale (int category, const char *locale)
        }
       else
        for (++category; category < __LC_LAST; ++category)
-         if (category != LC_ALL && newnames[category] != _nl_C_name)
+         if (category != LC_ALL && newnames[category] != _nl_C_name
+             && newnames[category] != _nl_global_locale.__names[category])
            free ((char *) newnames[category]);
 
       /* Critical section left.  */