On 6/7/17 9:46 PM, dualbus wrote: > *** /tmp/R6GbnO_locale.c 2017-06-07 20:40:25.575118629 -0500 > --- locale.c 2017-06-07 20:39:59.054419575 -0500 > *************** > *** 85,91 **** > textdomain (PACKAGE); > > locale_mb_cur_max = MB_CUR_MAX; > ! locale_utf8locale = locale_isutf8 (default_locale); > locale_shiftstates = mblen ((char *)NULL, 0); > } > > --- 85,98 ---- > textdomain (PACKAGE); > > locale_mb_cur_max = MB_CUR_MAX; > ! locale_utf8locale = 0; > ! #if defined (HAVE_SETLOCALE) > ! if (default_locale) > ! { > ! locale_utf8locale = locale_isutf8 (default_locale); > ! free (default_locale); > ! } > ! #endif /* HAVE_SETLOCALE */ > locale_shiftstates = mblen ((char *)NULL, 0); > }
This is a glibc issue. Bash keeps a copy of the default locale for its own purposes, and copies it because the return value from setlocale() is an opaque pointer. glibc happens to store it in malloc'd memory, but there is no requirement that setlocale() do so, and other systems (Mac OS X) do not. I'm not sure why this is considered a leak, though, since glibc keeps a handle on the memory for the current locale. Even though glibc allocates the memory for the current locale, the man page warns not to assume that: "A successful call to setlocale() returns an opaque string that corre- sponds to the locale set. This string may be allocated in static storage." Posix contains similar warning language. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/