Bug 21507 - setlocale changed behavior in glibc-2.2
Summary: setlocale changed behavior in glibc-2.2
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libc
Version: 7.0
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-30 06:45 UTC by Need Real Name
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-11-30 11:07:50 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2000-11-30 06:45:24 UTC
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 11:07:46 UTC
Working on a fix.

Comment 2 Jakub Jelinek 2000-12-19 09:29:02 UTC
Fixed in glibc-2.2-9.


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