From 965ae05ff5f66e31ead82e8a932963c8b617d0f7 Mon Sep 17 00:00:00 2001 From: YX Hao Date: Tue, 26 Dec 2023 19:02:03 +0800 Subject: [PATCH] wintls: move `UnloadSecurityLibrary` into `ssl_cleanup` --- src/init.c | 2 +- src/win-sspi.c | 5 ++--- src/wintls.c | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/init.c b/src/init.c index 5a79d007..1001a9c1 100644 --- a/src/init.c +++ b/src/init.c @@ -1971,7 +1971,7 @@ cleanup (void) host_cleanup (); log_cleanup (); netrc_cleanup (); -#if defined HAVE_SSL && !defined HAVE_WINTLS +#if defined HAVE_SSL ssl_cleanup (); #endif connect_cleanup (); diff --git a/src/win-sspi.c b/src/win-sspi.c index 2fa0fafa..187da8bd 100644 --- a/src/win-sspi.c +++ b/src/win-sspi.c @@ -89,12 +89,11 @@ bool LoadSecurityLibrary(void) { goto FAIL; } - atexit(UnloadSecurityLibrary); return true; FAIL: - UnloadSecurityLibrary(); - return false; + UnloadSecurityLibrary(); + return false; } void UnloadSecurityLibrary(void) { diff --git a/src/wintls.c b/src/wintls.c index eef6dbe5..3d30c551 100644 --- a/src/wintls.c +++ b/src/wintls.c @@ -1320,6 +1320,10 @@ bool ssl_init(void) { return true; } +void ssl_cleanup (void) { + UnloadSecurityLibrary(); +} + /* Perform the SSL/TLS handshake and wrap the connection handle reader and writer connection-oriented sockets (type SOCK_STREAM) */