diff options
-rw-r--r-- | examples/mimetest.c | 5 | ||||
-rw-r--r-- | imap4d/preauth.c | 1 | ||||
-rw-r--r-- | libmu_auth/ldap.c | 5 | ||||
-rw-r--r-- | mail/decode.c | 3 | ||||
-rw-r--r-- | mailbox/attachment.c | 3 | ||||
-rw-r--r-- | mailbox/filter.c | 16 | ||||
-rw-r--r-- | mailbox/filter_iconv.c | 1 | ||||
-rw-r--r-- | mailbox/mutil.c | 4 | ||||
-rw-r--r-- | mh/mh_list.c | 3 | ||||
-rw-r--r-- | mh/mhn.c | 13 |
10 files changed, 31 insertions, 23 deletions
diff --git a/examples/mimetest.c b/examples/mimetest.c index bca97af28..923e4d0ff 100644 --- a/examples/mimetest.c +++ b/examples/mimetest.c @@ -251,7 +251,10 @@ message_display_parts (mu_message_t msg, int indent) printf ("%*.*sBegin\n", indent, indent, ""); mu_message_get_body (part, &body); mu_body_get_stream (body, &str); - mu_filter_create (&str, str, encoding, 0, 0); + /* Make sure the original body stream is not closed when + str gets destroyed */ + mu_filter_create (&str, str, encoding, MU_FILTER_DECODE, + MU_STREAM_READ | MU_STREAM_NO_CLOSE); offset = 0; while (mu_stream_readline (str, buf, sizeof (buf), offset, &nbytes) == 0 && nbytes) diff --git a/imap4d/preauth.c b/imap4d/preauth.c index a9a2a5cc1..203cb2958 100644 --- a/imap4d/preauth.c +++ b/imap4d/preauth.c @@ -217,7 +217,6 @@ decode64_buf (const char *name, unsigned char **pbuf, size_t *psize) mu_stream_sequential_write (str, name, namelen); mu_stream_read (flt, (char*) buf, sizeof buf, 0, &size); mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); *pbuf = malloc (size); if (!*pbuf) return 1; diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c index 70d3e0fc2..3fdedfbe5 100644 --- a/libmu_auth/ldap.c +++ b/libmu_auth/ldap.c @@ -602,7 +602,6 @@ chk_md5 (const char *db_pass, const char *pass) mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL); mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); return memcmp (md5digest, d1, sizeof md5digest) == 0 ? 0 : MU_ERR_AUTH_FAILURE; @@ -629,13 +628,11 @@ chk_smd5 (const char *db_pass, const char *pass) if (!d1) { mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); return ENOMEM; } mu_stream_read (flt, (char*) d1, size, 0, &size); mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); if (size <= 16) { @@ -674,7 +671,6 @@ chk_sha (const char *db_pass, const char *pass) mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL); mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); return memcmp (sha1digest, d1, sizeof sha1digest) == 0 ? 0 : MU_ERR_AUTH_FAILURE; @@ -701,7 +697,6 @@ chk_ssha (const char *db_pass, const char *pass) if (!d1) { mu_stream_destroy (&flt, NULL); - mu_stream_destroy (&str, NULL); return ENOMEM; } diff --git a/mail/decode.c b/mail/decode.c index 2eb3a8287..4beadc93f 100644 --- a/mail/decode.c +++ b/mail/decode.c @@ -258,7 +258,8 @@ display_submessage (struct mime_descend_closure *closure, void *data) /* Can we decode. */ if (mu_filter_create(&d_stream, b_stream, closure->encoding, - MU_FILTER_DECODE, MU_STREAM_READ) == 0) + MU_FILTER_DECODE, + MU_STREAM_READ|MU_STREAM_NO_CLOSE) == 0) stream = d_stream; else stream = b_stream; diff --git a/mailbox/attachment.c b/mailbox/attachment.c index 26430fc93..8f02b4fbd 100644 --- a/mailbox/attachment.c +++ b/mailbox/attachment.c @@ -313,7 +313,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, content_encoding = "7bit"; ret = mu_filter_create (&info->stream, istream, content_encoding, - MU_FILTER_DECODE, MU_STREAM_READ); + MU_FILTER_DECODE, + MU_STREAM_READ | MU_STREAM_NO_CLOSE); free (content_encoding_mem); } } diff --git a/mailbox/filter.c b/mailbox/filter.c index 6a2e4d11d..e7ad3d20b 100644 --- a/mailbox/filter.c +++ b/mailbox/filter.c @@ -46,6 +46,8 @@ static void filter_destroy (mu_stream_t stream) { mu_filter_t filter = mu_stream_get_owner (stream); + if (!(stream->flags & MU_STREAM_NO_CLOSE)) + mu_stream_destroy (&filter->stream, mu_stream_get_owner (filter->stream)); if (filter->_destroy) filter->_destroy (filter); if (filter->property) @@ -165,7 +167,7 @@ mu_filter_get_list (mu_list_t *plist) int mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name, - int type, int direction) + int type, int flags) { mu_iterator_t iterator = NULL; mu_filter_record_t filter_record = NULL; @@ -204,14 +206,12 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name, if (found) { - int flags = 0; mu_filter_t filter; filter = calloc (1, sizeof (*filter)); if (filter == NULL) return ENOMEM; - mu_stream_get_flags (stream, &flags); status = mu_stream_create (pstream, flags | MU_STREAM_NO_CHECK, filter); if (status != 0) { @@ -221,7 +221,11 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name, filter->stream = stream; filter->filter_stream = *pstream; - filter->direction = (direction == 0) ? MU_STREAM_READ : direction; + filter->direction = (flags == 0) ? MU_STREAM_READ + : (flags + & (MU_STREAM_READ | + MU_STREAM_WRITE | + MU_STREAM_RDWR)); filter->type = type; status = mu_property_create (&(filter->property), filter); @@ -249,8 +253,8 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name, } } - mu_stream_set_open (*pstream, filter_open, filter ); - mu_stream_set_close (*pstream, filter_close, filter ); + mu_stream_set_open (*pstream, filter_open, filter); + mu_stream_set_close (*pstream, filter_close, filter); mu_stream_set_read (*pstream, filter_read, filter); mu_stream_set_readline (*pstream, filter_readline, filter); mu_stream_set_write (*pstream, filter_write, filter); diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c index c09d4631b..e47c5db25 100644 --- a/mailbox/filter_iconv.c +++ b/mailbox/filter_iconv.c @@ -114,6 +114,7 @@ _icvt_destroy (mu_stream_t stream) s->buf = NULL; if (s->cd != (iconv_t) -1) iconv_close (s->cd); + free (s); } static int _icvt_read (mu_stream_t stream, char *optr, size_t osize, diff --git a/mailbox/mutil.c b/mailbox/mutil.c index 19dbcc1c8..70bce589e 100644 --- a/mailbox/mutil.c +++ b/mailbox/mutil.c @@ -1329,8 +1329,8 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input, { mu_stream_t cvt; status = mu_filter_iconv_create (&cvt, filter, fromcode, tocode, - MU_STREAM_NO_CLOSE, - mu_default_fallback_mode); + MU_STREAM_NO_CLOSE, + mu_default_fallback_mode); if (status == 0) { if (mu_stream_open (cvt)) diff --git a/mh/mh_list.c b/mh/mh_list.c index 489d0285d..6d8c651ea 100644 --- a/mh/mh_list.c +++ b/mh/mh_list.c @@ -699,7 +699,8 @@ eval_body (struct eval_env *env) if (encoding) { int rc = mu_filter_create(&dstr, input, encoding, - MU_FILTER_DECODE, MU_STREAM_READ); + MU_FILTER_DECODE, + MU_STREAM_READ | MU_STREAM_NO_CLOSE); if (rc == 0) input = dstr; free (encoding); @@ -1122,8 +1122,9 @@ mhn_message_size (mu_message_t msg, size_t *psize) mu_message_get_header (msg, &hdr); _get_content_encoding (hdr, &encoding); - rc = mu_filter_create(&dstr, bstr, encoding, - MU_FILTER_DECODE, MU_STREAM_READ); + rc = mu_filter_create (&dstr, bstr, encoding, + MU_FILTER_DECODE, + MU_STREAM_READ | MU_STREAM_NO_CLOSE); free (encoding); if (rc == 0) { @@ -1272,8 +1273,8 @@ show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t ou return 0; } mu_body_get_stream (body, &bstr); - rc = mu_filter_create(&dstr, bstr, encoding, - MU_FILTER_DECODE, MU_STREAM_READ); + rc = mu_filter_create (&dstr, bstr, encoding, + MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_NO_CLOSE); if (rc == 0) bstr = dstr; cat_message (out, bstr); @@ -2052,10 +2053,12 @@ finish_text_msg (struct compose_env *env, mu_message_t *msg, int ascii) mu_message_get_body (*msg, &body); mu_body_get_stream (body, &input); rc = mu_filter_create (&fstr, input, "quoted-printable", - MU_FILTER_ENCODE, MU_STREAM_READ); + MU_FILTER_ENCODE, + MU_STREAM_READ | MU_STREAM_NO_CLOSE); if (rc == 0) { cat_message (output, fstr); + mu_stream_destroy (&fstr, NULL); mu_message_unref (*msg); *msg = newmsg; } |