summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-06-15 17:00:51 +0300
committerSergey Poznyakoff <gray@gnu.org>2020-06-15 17:27:15 +0300
commit45d54031f4e3f94d121b349b63f06c74ea1383d7 (patch)
tree005bb137a164a75e4db1d8f9b6fb7b2794988373 /include
parentdb3f8b9a2f1bb40a4b08e20e435f300fcfeb8928 (diff)
downloadmailutils-45d54031f4e3f94d121b349b63f06c74ea1383d7.tar.gz
mailutils-45d54031f4e3f94d121b349b63f06c74ea1383d7.tar.bz2
Fix long-standing memory leak in body.c
* include/mailutils/body.h (mu_body_ref, mu_body_unref): New functions. * include/mailutils/sys/body.h (_mu_body): New member ref_count. * libmailutils/mailbox/body.c: Keep body and body stream objects alive for as long as their reference counters are not zero. Rewrite transport stream code. * libmailutils/tests/modmesg.c: Use MU_ASSERT.
Diffstat (limited to 'include')
-rw-r--r--include/mailutils/body.h2
-rw-r--r--include/mailutils/sys/body.h8
2 files changed, 6 insertions, 4 deletions
diff --git a/include/mailutils/body.h b/include/mailutils/body.h
index 8e2e1d067..928dc6fec 100644
--- a/include/mailutils/body.h
+++ b/include/mailutils/body.h
@@ -42,6 +42,8 @@ extern int mu_body_set_size (mu_body_t,
extern int mu_body_lines (mu_body_t, size_t *);
extern int mu_body_set_lines (mu_body_t,
int (*_lines) (mu_body_t, size_t*), void *owner);
+extern void mu_body_ref (mu_body_t body);
+extern void mu_body_unref (mu_body_t body);
#ifdef __cplusplus
}
diff --git a/include/mailutils/sys/body.h b/include/mailutils/sys/body.h
index eee709c19..8cd67d9ac 100644
--- a/include/mailutils/sys/body.h
+++ b/include/mailutils/sys/body.h
@@ -30,10 +30,10 @@ extern "C" {
struct _mu_body
{
- void *owner;
- mu_stream_t stream;
- mu_stream_t rawstream;
- mu_stream_t fstream;
+ int ref_count; /* Reference counter */
+ void *owner; /* Owner object pointer */
+ mu_stream_t data_stream; /* Body content stream */
+ mu_stream_t temp_stream; /* RW temporary stream (for writing ro the body) */
int flags;
int (*_size) (mu_body_t, size_t*);

Return to:

Send suggestions and report system problems to the System administrator.