freebsd-dev/lib/libc/locale
Mark Johnston afd95785c0 newlocale(3): Fix a memory leak.
newlocale() optionally takes a "base" locale, from which components not
specified in the mask are inherited.  POSIX says that newlocale() may
modify "base" and return it, or free "base" and return a newly allocated
locale.  We were not doing either, so applications which use newlocale()
to modify an existing base locale end up leaking memory on FreeBSD.

This diff fixes the leak by releasing a reference to the base locale
before returning.  This is less efficient than modifying "base"
directly, but is simpler for an initial bug fix.  Also, update the man
page to clarify behaviour with respect to "base".

PR:		249416
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26522
2020-10-02 18:35:55 +00:00
..
ascii.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
big5.5 Use proper mdoc(7) macros for literal text and do not use Tn 2020-04-01 09:01:35 +00:00
big5.c
btowc.3
btowc.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
c16rtomb_iconv.c
c16rtomb.c Fix WITHOUT_ICONV build after r340276. 2018-11-14 09:06:15 +00:00
c32rtomb_iconv.c
c32rtomb.c Fix WITHOUT_ICONV build after r340276. 2018-11-14 09:06:15 +00:00
collate.c libc: Fix a few bugs in the xlocale collation code. 2020-01-09 20:49:26 +00:00
collate.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
collcmp.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
ctype_l.3
ctype.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
ctype.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
cXXrtomb_iconv.h Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
DESIGN.xlocale
digittoint.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
duplocale.3
euc.5 In FreeBSD 11 localedef(1) has replaced the mklocale(1) and colldef(1) 2019-09-10 07:47:52 +00:00
euc.c SPDX: Fix some License ID tags for libc. 2017-12-27 21:21:03 +00:00
fix_grouping.c localeconv: correct grouping and mon_grouping per C/POSIX 2019-12-19 17:01:25 +00:00
freelocale.3 Change the return type of freelocale(3) to void. 2016-07-29 17:18:47 +00:00
gb2312.5
gb2312.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
gb18030.5
gb18030.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
gbk.5
gbk.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
isalnum.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isalpha.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isascii.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isblank.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
iscntrl.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isctype.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
isdigit.3 Don't put multiple names on a single .Nm line. This fixes apropos(1) 2018-04-17 09:05:46 +00:00
isgraph.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isideogram.3
islower.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isphonogram.3
isprint.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
ispunct.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isrune.3
isspace.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
isspecial.3
isupper.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
iswalnum_l.3
iswalnum.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
iswctype.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
isxdigit.3 Don't put multiple names on a single .Nm line. This fixes apropos(1) 2018-04-17 09:05:46 +00:00
ldpart.c Add hybrid C.UTF-8 locale being identical to default C locale except 2018-11-04 22:13:22 +00:00
ldpart.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lmessages.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lmessages.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lmonetary.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lmonetary.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lnumeric.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
lnumeric.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
localeconv.3 localeconv(3): start sentences on new lines 2017-05-23 07:09:26 +00:00
localeconv.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
Makefile.inc Link localeconv(3) to localeconv_l(3) 2015-11-25 09:12:30 +00:00
mblen.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
mblen.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mblocal.h Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbrlen.3
mbrlen.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbrtoc16_iconv.c
mbrtoc16.c Fix WITHOUT_ICONV build after r340276. 2018-11-14 09:06:15 +00:00
mbrtoc32_iconv.c
mbrtoc32.c Fix WITHOUT_ICONV build after r340276. 2018-11-14 09:06:15 +00:00
mbrtocXX_iconv.h Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbrtowc.3
mbrtowc.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbsinit.3
mbsinit.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
mbsnrtowcs.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbsrtowcs.3 mbsrtowcs(3): Clarify the RETURN VALUES section 2020-08-07 16:56:43 +00:00
mbsrtowcs.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mbstowcs.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
mbstowcs.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
mbtowc.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
mbtowc.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
mskanji.5
mskanji.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
multibyte.3 In FreeBSD 11 localedef(1) has replaced the mklocale(1) and colldef(1) 2019-09-10 07:47:52 +00:00
newlocale.3 newlocale(3): Fix a memory leak. 2020-10-02 18:35:55 +00:00
nextwctype.3
nextwctype.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
nl_langinfo.3
nl_langinfo.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
nomacros.c
none.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
querylocale.3
rpmatch.3
rpmatch.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
rune.c libc: Fix a few bugs in the xlocale collation code. 2020-01-09 20:49:26 +00:00
runefile.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
runetype.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
setlocale.3 setlocale(3): Add an EXAMPLES section and add LANG category 2020-08-07 17:25:56 +00:00
setlocale.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
setlocale.h libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
setrunelocale.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
Symbol.map
table.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
toascii.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
tolower.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
tolower.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
toupper.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
toupper.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
towlower.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
towupper.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
uselocale.3
utf8.5 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
utf8.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcrtomb.3
wcrtomb.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
wcsftime.3
wcsftime.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcsnrtombs.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
wcsrtombs.3
wcsrtombs.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
wcstod.3
wcstod.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcstof.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcstoimax.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wcstol.3
wcstol.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wcstold.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcstoll.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wcstombs.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
wcstombs.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcstoul.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wcstoull.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wcstoumax.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
wctob.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wctomb.3 Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
wctomb.c Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
wctrans.3
wctrans.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wctype.3
wctype.c libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
wcwidth.3
wcwidth.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
xlocale_private.h Reset persistent mbstates when rune locale encoding changes. 2018-11-09 03:32:53 +00:00
xlocale.3
xlocale.c newlocale(3): Fix a memory leak. 2020-10-02 18:35:55 +00:00