Commit a250bc91 a250bc91a29211e4792f2098769363a820b16823 by Sergey Poznyakoff

Fix memory leak. Patch provided by Frederic Gobry <frederic.gobry@smartdata.ch>

1 parent f6b7a4d2
...@@ -76,6 +76,10 @@ stream_destroy (stream_t *pstream, void *owner) ...@@ -76,6 +76,10 @@ stream_destroy (stream_t *pstream, void *owner)
76 stream_close(stream); 76 stream_close(stream);
77 if (stream->rbuffer.base) 77 if (stream->rbuffer.base)
78 free (stream->rbuffer.base); 78 free (stream->rbuffer.base);
79
80 if (stream->_destroy)
81 stream->_destroy (stream);
82
79 free (stream); 83 free (stream);
80 } 84 }
81 *pstream = NULL; 85 *pstream = NULL;
......
...@@ -84,15 +84,6 @@ _tcp_open (stream_t stream) ...@@ -84,15 +84,6 @@ _tcp_open (stream_t stream)
84 84
85 stream_get_flags(stream, &flags); 85 stream_get_flags(stream, &flags);
86 86
87 if (tcp->state == TCP_STATE_INIT)
88 {
89 tcp->port = port;
90 /* FIXME: this seems very strange, it is: tcp->host = strdup(tcp->host)
91 is this really intended? */
92 if ((tcp->host = strdup (host)) == NULL)
93 return ENOMEM;
94 }
95
96 switch (tcp->state) 87 switch (tcp->state)
97 { 88 {
98 case TCP_STATE_INIT: 89 case TCP_STATE_INIT:
...@@ -221,8 +212,6 @@ _tcp_destroy (stream_t stream) ...@@ -221,8 +212,6 @@ _tcp_destroy (stream_t stream)
221 if (tcp->fd != -1) 212 if (tcp->fd != -1)
222 close (tcp->fd); 213 close (tcp->fd);
223 214
224 if(tcp->host)
225 free (tcp->host);
226 free (tcp); 215 free (tcp);
227 } 216 }
228 217
......