diff options
author | ngie <ngie@FreeBSD.org> | 2017-01-07 09:17:45 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-01-07 09:17:45 +0000 |
commit | 067d2ed2b3eba75e7dfd986e119406cb3e472849 (patch) | |
tree | a82bc59e66d94ef0b0045c417f47989639ee047d /contrib/netbsd-tests/lib/libc/string/t_strlen.c | |
parent | 5dba8e8dc119241ee8d6222279c0da2ce10f9efe (diff) | |
download | FreeBSD-src-067d2ed2b3eba75e7dfd986e119406cb3e472849.zip FreeBSD-src-067d2ed2b3eba75e7dfd986e119406cb3e472849.tar.gz |
MFC r311249:
{strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use
CID: 978299, 978300
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/string/t_strlen.c')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/string/t_strlen.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/string/t_strlen.c b/contrib/netbsd-tests/lib/libc/string/t_strlen.c index 66158fd..7483dc6 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_strlen.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strlen.c @@ -40,6 +40,9 @@ ATF_TC_HEAD(strlen_basic, tc) ATF_TC_BODY(strlen_basic, tc) { +#ifdef __FreeBSD__ + void *dl_handle; +#endif /* try to trick the compiler */ size_t (*strlen_fn)(const char *); @@ -107,7 +110,12 @@ ATF_TC_BODY(strlen_basic, tc) * During testing it is useful have the rest of the program * use a known good version! */ +#ifdef __FreeBSD__ + dl_handle = dlopen(NULL, RTLD_LAZY); + strlen_fn = dlsym(dl_handle, "test_strlen"); +#else strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen"); +#endif if (!strlen_fn) strlen_fn = strlen; @@ -134,6 +142,9 @@ ATF_TC_BODY(strlen_basic, tc) } } } +#ifdef __FreeBSD__ + (void)dlclose(dl_handle); +#endif } ATF_TC(strlen_huge); |