diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2021-09-12 19:27:21 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2021-09-12 19:27:21 -0700 |
commit | a3446b5c6e0879b289287c9a87a57cbdc95e99da (patch) | |
tree | f2731a8a700685eb2db8aaac44555766577f25d3 | |
parent | c9f6bdda4c714ceeeaa17d473dd649fd41cc245d (diff) | |
download | libcap2-a3446b5c6e0879b289287c9a87a57cbdc95e99da.tar.gz |
Free _cap_proc_dir on exit.
Credit to yan12125 for finding this bug:
https://bugzilla.kernel.org/show_bug.cgi?id=214373
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | libcap/cap_text.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libcap/cap_text.c b/libcap/cap_text.c index 013eb1e..1004aae 100644 --- a/libcap/cap_text.c +++ b/libcap/cap_text.c @@ -674,6 +674,19 @@ static __u32 _parse_vec_string(__u32 *vals, const char *c, int invert) static char *_cap_proc_dir; /* + * If the constructor is called (see cap_alloc.c) then we'll need the + * corresponding destructor. + */ +__attribute__((destructor (300))) static void _cleanup_libcap(void) +{ + if (_cap_proc_dir == NULL) { + return; + } + cap_free(_cap_proc_dir); + _cap_proc_dir = NULL; +} + +/* * cap_proc_root reads and (optionally: when root != NULL) changes * libcap's notion of where the "/proc" filesystem is mounted. It * defaults to the value "/proc". Note, this is a global value and not |