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)
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
Unknown Object (File)
Jan 12 2024, 7:17 PM
Unknown Object (File)
Jan 11 2024, 9:15 PM
Unknown Object (File)
Dec 20 2023, 7:01 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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33732
Build 30964: arc lint + arc unit

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.