* locale/setlocale.c (setlocale): Avoid duplicating locale names
	if we can reuse old strings.
This commit is contained in:
Ulrich Drepper 2003-12-31 22:46:53 +00:00
parent 520ec963af
commit a31f867a42
4 changed files with 33 additions and 12 deletions

View File

@ -1,5 +1,8 @@
2003-12-31 Ulrich Drepper <drepper@redhat.com> 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 * inet/rcmd.c: Provide better error message in case of unknown
host. Remove USE_IN_LIBIO. host. Remove USE_IN_LIBIO.

View 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> 2003-12-29 Jakub Jelinek <jakub@redhat.com>
* sysdeps/ia64/tls.h: Include dl-sysdep.h. * sysdeps/ia64/tls.h: Include dl-sysdep.h.

View File

@ -441,6 +441,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
char *line = NULL; char *line = NULL;
size_t linelen = 0; size_t linelen = 0;
uintptr_t last_to = 0;
while (! feof_unlocked (fp)) while (! feof_unlocked (fp))
{ {
@ -449,8 +450,9 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
uintptr_t from; uintptr_t from;
uintptr_t to; uintptr_t to;
if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) == 2 if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
&& from <= (uintptr_t) __libc_stack_end continue;
if (from <= (uintptr_t) __libc_stack_end
&& (uintptr_t) __libc_stack_end < to) && (uintptr_t) __libc_stack_end < to)
{ {
/* Found the entry. Now we have the info we need. */ /* 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 #else
attr->__stackaddr = (void *) to; attr->__stackaddr = (void *) to;
/* The limit might be too high. This is a bogus /* The limit might be too high. */
situation but try to avoid making it worse. */ if ((size_t) attr->__stacksize
if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr) > (size_t) attr->__stackaddr - last_to)
attr->__stacksize = (size_t) attr->__stackaddr; attr->__stacksize = (size_t) attr->__stackaddr - last_to;
#endif #endif
/* We succeed and no need to look further. */ /* We succeed and no need to look further. */
ret = 0; ret = 0;
break; break;
} }
last_to = to;
} }
fclose (fp); fclose (fp);

View File

@ -322,19 +322,27 @@ setlocale (int category, const char *locale)
break; break;
} }
/* We must not simply free a global locale since we have no /* We must not simply free a global locale since we have
control over the usage. So we mark it as un-deletable. */ 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) if (newdata[category]->usage_count != UNDELETABLE)
newdata[category]->usage_count = UNDELETABLE; newdata[category]->usage_count = UNDELETABLE;
/* Make a copy of locale name. */ /* Make a copy of locale name. */
if (newnames[category] != _nl_C_name) if (newnames[category] != _nl_C_name)
{
if (strcmp (newnames[category],
_nl_global_locale.__names[category]) == 0)
newnames[category] = _nl_global_locale.__names[category];
else
{ {
newnames[category] = __strdup (newnames[category]); newnames[category] = __strdup (newnames[category]);
if (newnames[category] == NULL) if (newnames[category] == NULL)
break; break;
} }
} }
}
/* Create new composite name. */ /* Create new composite name. */
composite = (category >= 0 composite = (category >= 0
@ -356,7 +364,8 @@ setlocale (int category, const char *locale)
} }
else else
for (++category; category < __LC_LAST; ++category) 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]); free ((char *) newnames[category]);
/* Critical section left. */ /* Critical section left. */