diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-11-07 14:46:20 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-11-07 14:46:20 +0000 |
commit | a250bc91a29211e4792f2098769363a820b16823 (patch) | |
tree | 21d1a270cb5426a36faabb1b1a5ddd0bd789ed6a | |
parent | f6b7a4d2cbf509170cb3dc93091bcb108e69e3cc (diff) | |
download | mailutils-a250bc91a29211e4792f2098769363a820b16823.tar.gz mailutils-a250bc91a29211e4792f2098769363a820b16823.tar.bz2 |
Fix memory leak. Patch provided by Frederic Gobry <frederic.gobry@smartdata.ch>
-rw-r--r-- | mailbox/stream.c | 4 | ||||
-rw-r--r-- | mailbox/tcp.c | 11 |
2 files changed, 4 insertions, 11 deletions
diff --git a/mailbox/stream.c b/mailbox/stream.c index d88ac462d..13bfcc947 100644 --- a/mailbox/stream.c +++ b/mailbox/stream.c @@ -73,12 +73,16 @@ stream_destroy (stream_t *pstream, void *owner) stream_t stream = *pstream; if ((stream->flags & MU_STREAM_NO_CHECK) || stream->owner == owner) { stream_close(stream); if (stream->rbuffer.base) free (stream->rbuffer.base); + + if (stream->_destroy) + stream->_destroy (stream); + free (stream); } *pstream = NULL; } } diff --git a/mailbox/tcp.c b/mailbox/tcp.c index 17eb2fcaf..87f4f8ba1 100644 --- a/mailbox/tcp.c +++ b/mailbox/tcp.c @@ -81,21 +81,12 @@ _tcp_open (stream_t stream) char* host = tcp->host; int port = tcp->port; int flags; stream_get_flags(stream, &flags); - if (tcp->state == TCP_STATE_INIT) - { - tcp->port = port; -/* FIXME: this seems very strange, it is: tcp->host = strdup(tcp->host) - is this really intended? */ - if ((tcp->host = strdup (host)) == NULL) - return ENOMEM; - } - switch (tcp->state) { case TCP_STATE_INIT: if (tcp->fd == -1) { if ((tcp->fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) @@ -218,14 +209,12 @@ _tcp_destroy (stream_t stream) if (tcp->host) free (tcp->host); if (tcp->fd != -1) close (tcp->fd); - if(tcp->host) - free (tcp->host); free (tcp); } int tcp_stream_create (stream_t * stream, const char* host, int port, int flags) { |