swrap: Avoid dclose(RTLD_NEXT) In case the libc was not found and RTLD_NEXT is used instead, we should not dlclose it, otherwise mayhem happens. Signed-off-by: Samuel Thibault diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index ec8321f..cc9e17d 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -7831,10 +7831,18 @@ void swrap_destructor(void) SAFE_FREE(sockets); - if (swrap.libc.handle != NULL) { + if (swrap.libc.handle != NULL +#ifdef RTLD_NEXT + && swrap.libc.handle != RTLD_NEXT +#endif + ) { dlclose(swrap.libc.handle); } - if (swrap.libc.socket_handle) { + if (swrap.libc.socket_handle +#ifdef RTLD_NEXT + && swrap.libc.socket_handle != RTLD_NEXT +#endif + ) { dlclose(swrap.libc.socket_handle); } }