summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-07-02 13:40:46 +0200
committerPierre Ossman <ossman@cendio.se>2018-07-02 13:40:46 +0200
commit74b2129e09ee753f952132d317afe5b503fec07e (patch)
tree64f5a320b00f62c6a91e3210105015efd1e0a741
parentdaaa48108a0156473b4f8d63265df2004977ba93 (diff)
downloadrdesktop-master.zip
Free socket buffers on disconnectHEADmaster
Otherwise we would leak the memory on every reconnect (and exit).
-rw-r--r--tcp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tcp.c b/tcp.c
index 979feae..1db56f2 100644
--- a/tcp.c
+++ b/tcp.c
@@ -613,6 +613,8 @@ tcp_connect(char *server)
void
tcp_disconnect(void)
{
+ int i;
+
if (g_ssl)
{
if (!g_network_error)
@@ -625,6 +627,17 @@ tcp_disconnect(void)
TCP_CLOSE(g_sock);
g_sock = -1;
+
+ g_in.size = 0;
+ xfree(g_in.data);
+ g_in.data = NULL;
+
+ for (i = 0; i < STREAM_COUNT; i++)
+ {
+ g_out[i].size = 0;
+ xfree(g_out[i].data);
+ g_out[i].data = NULL;
+ }
}
char *