HomeFreeBSD

newlocale(3): Fix a memory leak.

Description

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

Details

Provenance
markjAuthored on
Differential Revision
D26522: newlocale(3): Fix a memory leak.
Parents
rS366374: Bump __FreeBSD_version after latest linuxkpi changes
Branches
Unknown
Tags
Unknown