diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-02-17 09:28:11 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-02-17 09:28:11 +0200 |
commit | afaecb9b14696dfe12e2f2f501906dbd01cec27e (patch) | |
tree | 9888dc45d0251b69ea294b9ac9597a92c36dc086 | |
parent | 43fb1f13a88924654da3d45bbb820a7206a69d55 (diff) | |
download | mailutils-afaecb9b14696dfe12e2f2f501906dbd01cec27e.tar.gz mailutils-afaecb9b14696dfe12e2f2f501906dbd01cec27e.tar.bz2 |
Fix memory leak in mu_stream_destroy
* libmailutils/stream/stream.c (mu_stream_destroy): Free
buffer space.
(mu_stream_set_buffer,mu_stream_getdelim): Use stdlib allocation
functions instead of mu wrappers.
-rw-r--r-- | libmailutils/stream/stream.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libmailutils/stream/stream.c b/libmailutils/stream/stream.c index 2f1151c9e..39827af34 100644 --- a/libmailutils/stream/stream.c +++ b/libmailutils/stream/stream.c @@ -260,6 +260,12 @@ mu_stream_destroy (mu_stream_t *pstream) if (str && (str->ref_count == 0 || --str->ref_count == 0)) { mu_stream_close (str); + if (str->buftype != mu_buffer_none) + { + free (str->buffer); + str->buffer = NULL; + str->buftype = mu_buffer_none; + } if (str->done) str->done (str); if (str->destroy) @@ -553,7 +559,7 @@ mu_stream_set_buffer (mu_stream_t stream, enum mu_buffer_type type, return 0; } - stream->buffer = mu_alloc (size); + stream->buffer = malloc (size); if (stream->buffer == NULL) { stream->buftype = mu_buffer_none; @@ -899,7 +905,7 @@ mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize, { char *new_lineptr; n = 120; - new_lineptr = mu_realloc (lineptr, n); + new_lineptr = realloc (lineptr, n); if (new_lineptr == NULL) return ENOMEM; lineptr = new_lineptr; @@ -925,7 +931,7 @@ mu_stream_getdelim (mu_stream_t stream, char **pbuf, size_t *psize, break; } - new_lineptr = mu_realloc (lineptr, needed); + new_lineptr = realloc (lineptr, needed); if (new_lineptr == NULL) { rc = ENOMEM; |