global: Ensure we free our SSL context.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/src/global.c b/src/global.c
index 9f1a0bf..3f20bfd 100644
--- a/src/global.c
+++ b/src/global.c
@@ -116,6 +116,20 @@ static void init_ssl(void)
#endif
}
+/**
+ * This function aims to clean-up the SSL context which
+ * we allocated.
+ */
+static void uninit_ssl(void)
+{
+#ifdef GIT_OPENSSL
+ if (git__ssl_ctx) {
+ SSL_CTX_free(git__ssl_ctx);
+ git__ssl_ctx = NULL;
+ }
+#endif
+}
+
int git_openssl_set_locking(void)
{
#ifdef GIT_OPENSSL
@@ -333,6 +347,7 @@ int git_libgit2_shutdown(void)
/* Shut down any subsystems that have global state */
git__shutdown();
+ uninit_ssl();
ptr = pthread_getspecific(_tls_key);
pthread_setspecific(_tls_key, NULL);
@@ -391,6 +406,7 @@ int git_libgit2_shutdown(void)
git__shutdown();
git__global_state_cleanup(&__state);
+ uninit_ssl();
return 0;
}