Bug 21507 - setlocale changed behavior in glibc-2.2
setlocale changed behavior in glibc-2.2
Status: CLOSED ERRATA
Product: Red Hat Linux
Classification: Retired
Component: libc (Show other bugs)
7.0
All Linux
high Severity high
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-11-30 01:45 EST by Need Real Name
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-11-30 06:07:50 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-11-30 01:45:24 EST
I submitted this before to bug-glibc (#77294).  However, it appears to 
have been closed without a thorough reading.

The recommended usage of setlocale in the libc info pages is
    char *tmp = strdup (setlocale (LC_NUMERIC, NULL));
    setlocale (LC_NUMERIC, "C");
    <operation>
    setlocale (LC_NUMERIC, tmp);
    free (tmp);

This interface implies that setlocale copies the string being passed in.  
If it didn't the last setlocale (... tmp) would store a pointer to a freed 
string.  Unfortunately, this appears to have happened.  The next time 
through this type of operation setlocale (.. NULL) returns the freed 
pointer.  When we attempt to assign that later the sanity checks realize 
it is invalid, and silently switches to "C".  The program seems to work, 
but LC_NUMERIC is now wrong.

This needs to be addressed before glibc-2.2 gets too widely used.  I'm 
already receiving bug reports in gnumeric as a result.  If there is 
anything I can do the help please contact me.

Thanks
Comment 1 Jakub Jelinek 2000-11-30 06:07:46 EST
Working on a fix.
Comment 2 Jakub Jelinek 2000-12-19 04:29:02 EST
Fixed in glibc-2.2-9.

Note You need to log in before you can comment on or make changes to this bug.