Bug 36626 - login_cap(3) incorrectly claims that all resources freed.
Summary: login_cap(3) incorrectly claims that all resources freed.
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 5.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-01 20:20 UTC by Simon J. Gerraty
Modified: 2017-12-31 22:35 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon J. Gerraty 2002-04-01 20:20:01 UTC
	
login_cap(3) states:

     Note that with all functions in this group, you should not call free(3)
     on any pointers returned.  Memory allocated during retrieval or process-
     ing of capability tags is automatically reused by subsequent calls to
     functions in this group, or deallocated on calling login_close().

this is incorrect.  Functions like login_getcapstr() simply return
either the default passed to them or the string malloc'd by cgetstr().
No book keeping is done to ensure that that string is free()'d when needed.

Actually implementing the above promise is probably a tall order.
It might be better to document which functions do indeed need free() called 
and with the warning that one should use variables for default values
so that one can later tell if free is needed or not.

Alternatively login_getcapstr() could strdup(def), so that free() is always 
needed.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:35 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped