Fix memory leak. Patch provided by Frederic Gobry <frederic.gobry@smartdata.ch>
Showing
2 changed files
with
4 additions
and
11 deletions
... | @@ -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 | ... | ... |
-
Please register or sign in to post a comment