From 72e4e7291fd077530929e14e0e6507115e6e6c5d Mon Sep 17 00:00:00 2001 From: wiffel Date: Tue, 24 Feb 2015 22:01:07 +0100 Subject: [PATCH] Add SSLFree after SLShutdown to prevent memory leak --- lib/pure/net.nim | 2 ++ lib/pure/sockets.nim | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 5e5c4f8ec6..bed7515420 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -454,6 +454,8 @@ proc close*(socket: Socket) = # shutdown i.e not wait for the peers "close notify" alert with a second # call to SSLShutdown let res = SSLShutdown(socket.sslHandle) + SSLFree(socket.sslHandle) + socket.sslHandle = nil if res == 0: discard elif res != 1: diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 8ac5d4f091..3afb545c8d 100644 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -657,6 +657,8 @@ proc close*(socket: Socket) = when defined(ssl): if socket.isSSL: discard SSLShutdown(socket.sslHandle) + SSLFree(socket.sslHandle) + socket.sslHandle = nil proc getServByName*(name, proto: string): Servent {.tags: [ReadIOEffect].} = ## Searches the database from the beginning and finds the first entry for