diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-04 19:23:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-04 19:45:21 -0400 |
commit | c50537fd9462af45f0a53aa4f0d5ca03a08fc41e (patch) | |
tree | d61b8ad3ca023d0a810def6a01b40c624b0d2da7 /src/lib/tls/tortls_nss.c | |
parent | 274efb126324f3f8a7e98b15a697c0038a9803d0 (diff) | |
download | tor-c50537fd9462af45f0a53aa4f0d5ca03a08fc41e.tar.gz tor-c50537fd9462af45f0a53aa4f0d5ca03a08fc41e.zip |
Fix a pair of remaining leaks in tortls_nss.c
Fun fact: PR_Close leaks memory if its socket is not valid.
Diffstat (limited to 'src/lib/tls/tortls_nss.c')
-rw-r--r-- | src/lib/tls/tortls_nss.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/tls/tortls_nss.c b/src/lib/tls/tortls_nss.c index 548a817e63..8e6c0d2d77 100644 --- a/src/lib/tls/tortls_nss.c +++ b/src/lib/tls/tortls_nss.c @@ -361,7 +361,13 @@ tor_tls_new(tor_socket_t sock, int is_server) (void)sock; tor_tls_context_t *ctx = tor_tls_context_get(is_server); - PRFileDesc *tcp = PR_ImportTCPSocket(sock); + PRFileDesc *tcp = NULL; + if (SOCKET_OK(sock)) { + tcp = PR_ImportTCPSocket(sock); + } else { + tcp = PR_NewTCPSocket(); + } + if (!tcp) return NULL; |