summaryrefslogtreecommitdiff
path: root/libmailutils/tests
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 /libmailutils/tests
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 'libmailutils/tests')
-rw-r--r--libmailutils/tests/modmesg.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libmailutils/tests/modmesg.c b/libmailutils/tests/modmesg.c
index e34d1ddd3..f6dd28006 100644
--- a/libmailutils/tests/modmesg.c
+++ b/libmailutils/tests/modmesg.c
@@ -36,12 +36,12 @@ main (int argc, char **argv)
mu_set_program_name (argv[0]);
mu_static_memory_stream_create (&stream, text, strlen (text));
- assert (mu_stream_to_message (stream, &msg) == 0);
+ MU_ASSERT (mu_stream_to_message (stream, &msg));
mu_stream_unref (stream);
- assert (mu_message_get_header (msg, &hdr) == 0);
- assert (mu_message_get_body (msg, &body) == 0);
- assert (mu_body_get_streamref (body, &stream) == 0);
- assert (mu_stream_seek (stream, 0, MU_SEEK_END, NULL) == 0);
+ MU_ASSERT (mu_message_get_header (msg, &hdr));
+ MU_ASSERT (mu_message_get_body (msg, &body));
+ MU_ASSERT (mu_body_get_streamref (body, &stream));
+ MU_ASSERT (mu_stream_seek (stream, 0, MU_SEEK_END, NULL));
for (i = 1; i < argc; i++)
{
@@ -60,7 +60,7 @@ main (int argc, char **argv)
*p++ = 0;
while (*p && mu_isspace (*p))
p++;
- assert (mu_header_set_value (hdr, argv[i], p, 1) == 0);
+ MU_ASSERT (mu_header_set_value (hdr, argv[i], p, 1));
}
else if (strcmp (argv[i], "-l") == 0)
{
@@ -73,7 +73,7 @@ main (int argc, char **argv)
assert (*p == 0);
if (off < 0)
whence = MU_SEEK_END;
- assert (mu_stream_seek (stream, off, whence, NULL) == 0);
+ MU_ASSERT (mu_stream_seek (stream, off, whence, NULL));
}
else if (strcmp (argv[i], "-t") == 0)
{
@@ -88,8 +88,8 @@ main (int argc, char **argv)
exit (1);
}
else
- assert (mu_stream_write (stream, ws.ws_wordv[0],
- strlen (ws.ws_wordv[0]), NULL) == 0);
+ MU_ASSERT (mu_stream_write (stream, ws.ws_wordv[0],
+ strlen (ws.ws_wordv[0]), NULL));
mu_wordsplit_free (&ws);
}
else
@@ -97,8 +97,8 @@ main (int argc, char **argv)
}
mu_stream_unref (stream);
- assert (mu_message_get_streamref (msg, &stream) == 0);
- assert (mu_stream_copy (mu_strout, stream, 0, NULL) == 0);
+ MU_ASSERT (mu_message_get_streamref (msg, &stream));
+ MU_ASSERT (mu_stream_copy (mu_strout, stream, 0, NULL));
mu_stream_unref (stream);
return 0;

Return to:

Send suggestions and report system problems to the System administrator.