diff options
| author | Patrick Steinhardt <ps@pks.im> | 2017-05-02 13:37:15 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2017-05-02 14:46:15 +0200 |
| commit | 2ce2a48f2dfe6a92c0418f5c00e955039fdd0b96 (patch) | |
| tree | 3b88b7a1c492f0c4e86030a1060e5a8223edaf1a /src/transports/ssh.c | |
| parent | 8c027351cb5a3bb16f279795f32027c92f61039a (diff) | |
| download | libgit2-2ce2a48f2dfe6a92c0418f5c00e955039fdd0b96.tar.gz | |
transports: ssh: clean up after libssh2 on exit
After calling `libssh2_init`, we need to clean up after the library by
executing `libssh2_exit` as soon as we exit. Register a shutdown handler
to do so which simply calls `libssh2_exit`. This fixes several memory
leaks.
Diffstat (limited to 'src/transports/ssh.c')
| -rw-r--r-- | src/transports/ssh.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c index d195d58ad..4c55e3f2a 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -9,6 +9,7 @@ #include <libssh2.h> #endif +#include "global.h" #include "git2.h" #include "buffer.h" #include "netops.h" @@ -893,6 +894,13 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p #endif } +#ifdef GIT_SSH +static void shutdown_ssh(void) +{ + libssh2_exit(); +} +#endif + int git_transport_ssh_global_init(void) { #ifdef GIT_SSH @@ -901,6 +909,7 @@ int git_transport_ssh_global_init(void) return -1; } + git__on_shutdown(shutdown_ssh); return 0; #else |
