Page MenuHomeFreeBSD

newlocale(3): Fix a memory leak.
ClosedPublic

Authored by markj on Sep 22 2020, 4:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 12:49 AM
Unknown Object (File)
Mon, Apr 22, 12:36 AM
Unknown Object (File)
Sat, Apr 20, 6:24 PM
Unknown Object (File)
Mar 2 2024, 2:12 AM
Unknown Object (File)
Feb 25 2024, 12:21 AM
Unknown Object (File)
Jan 29 2024, 4:22 PM
Unknown Object (File)
Jan 22 2024, 9:11 PM
Unknown Object (File)
Jan 22 2024, 9:08 PM
Subscribers

Details

Summary

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 are 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 wrt to "base".

Test Plan

Use the test program provided with PR 249416.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Sep 22 2020, 4:45 PM
markj created this revision.
markj added a reviewer: yuripv.
markj added a subscriber: leres.
This revision was not accepted when it landed; it landed in state Needs Review.Oct 2 2020, 6:36 PM
This revision was automatically updated to reflect the committed changes.