From e208031a9ff3d83617ca3928cb3fa2bcfb4ca31e Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 7 Jan 2017 09:18:11 +0000 Subject: MFC r311249: {strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use CID: 978299, 978300 --- contrib/netbsd-tests/lib/libc/string/t_strchr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'contrib/netbsd-tests/lib/libc/string/t_strchr.c') diff --git a/contrib/netbsd-tests/lib/libc/string/t_strchr.c b/contrib/netbsd-tests/lib/libc/string/t_strchr.c index 958b186..4556b2c 100644 --- a/contrib/netbsd-tests/lib/libc/string/t_strchr.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strchr.c @@ -58,6 +58,9 @@ ATF_TC_HEAD(strchr_basic, tc) ATF_TC_BODY(strchr_basic, tc) { +#ifdef __FreeBSD__ + void *dl_handle; +#endif unsigned int t, a; char *off; char buf[32]; @@ -245,8 +248,12 @@ ATF_TC_BODY(strchr_basic, tc) "abcdefgh/abcdefgh/", }; - +#ifdef __FreeBSD__ + dl_handle = dlopen(NULL, RTLD_LAZY); + strchr_fn = dlsym(dl_handle, "test_strlen"); +#else strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr"); +#endif if (!strchr_fn) strchr_fn = strchr; @@ -281,6 +288,9 @@ ATF_TC_BODY(strchr_basic, tc) verify_strchr(buf + a, 0xff, t, a); } } +#ifdef __FreeBSD__ + (void)dlclose(dl_handle); +#endif } ATF_TP_ADD_TCS(tp) -- cgit v1.1