summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-04 19:23:55 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-04 19:45:21 -0400
commitc50537fd9462af45f0a53aa4f0d5ca03a08fc41e (patch)
treed61b8ad3ca023d0a810def6a01b40c624b0d2da7
parent274efb126324f3f8a7e98b15a697c0038a9803d0 (diff)
downloadtor-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.
-rw-r--r--src/lib/tls/tortls_nss.c8
-rw-r--r--src/test/test_router.c2
2 files changed, 9 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;
diff --git a/src/test/test_router.c b/src/test/test_router.c
index c6a2452c8c..14e739d6fc 100644
--- a/src/test/test_router.c
+++ b/src/test/test_router.c
@@ -52,6 +52,8 @@ NS(router_get_my_routerinfo)(void)
mock_routerinfo->onion_pkey = crypto_pk_dup_key(tap_key);
mock_routerinfo->bandwidthrate = 9001;
mock_routerinfo->bandwidthburst = 9002;
+ crypto_pk_free(ident_key);
+ crypto_pk_free(tap_key);
}
return mock_routerinfo;