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, Nov 25, 6:20 AM
Unknown Object (File)
Nov 23 2024, 4:48 AM
Unknown Object (File)
Nov 21 2024, 9:39 AM
Unknown Object (File)
Nov 20 2024, 5:40 AM
Unknown Object (File)
Nov 19 2024, 2:14 PM
Unknown Object (File)
Nov 18 2024, 7:35 PM
Unknown Object (File)
Nov 18 2024, 7:26 PM
Unknown Object (File)
Nov 9 2024, 12:59 AM
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.