Commit 76c508f8 76c508f88d9026915072af5ebb4055dc121154d5 by Sergey Poznyakoff

Fix indirect memory leak in mu_decode_filter.

* include/mailutils/stream.h (mu_stream_clr_flags): New function.
* mailbox/stream.c (mu_stream_clr_flags): New function.
* mailbox/mapfile_stream.c (_mapfile_open): Avoid unnecessary
boolean operation.
* mailbox/mutil.c (mu_decode_filter): Use mu_stream_clr_flags
to clear bits.
1 parent 16ea05b7
......@@ -129,6 +129,7 @@ extern void mu_stream_set_owner (mu_stream_t, void* owner);
extern int mu_stream_get_flags (mu_stream_t, int *pflags);
extern int mu_stream_set_flags (mu_stream_t, int flags);
extern int mu_stream_clr_flags (mu_stream_t, int flags);
extern int mu_stream_get_property (mu_stream_t, mu_property_t *);
extern int mu_stream_set_property (mu_stream_t, mu_property_t, void *);
......
......@@ -335,7 +335,7 @@ _mapfile_open (mu_stream_t stream)
else
mfs->ptr = NULL;
mfs->flags = mflag;
mu_stream_set_flags (stream, flags |MU_STREAM_NO_CHECK);
mu_stream_set_flags (stream, MU_STREAM_NO_CHECK);
return 0;
}
......
......@@ -1337,10 +1337,7 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input,
mu_stream_destroy (&cvt, mu_stream_get_owner (cvt));
else
{
int flags;
mu_stream_get_flags (cvt, &flags);
flags &= ~MU_STREAM_NO_CLOSE;
mu_stream_set_flags (cvt, flags);
mu_stream_clr_flags (cvt, MU_STREAM_NO_CLOSE);
filter = cvt;
}
}
......
......@@ -80,7 +80,7 @@ mu_stream_destroy (mu_stream_t *pstream, void *owner)
mu_stream_t stream = *pstream;
if ((stream->flags & MU_STREAM_NO_CHECK) || stream->owner == owner)
{
mu_stream_close(stream);
mu_stream_close (stream);
if (stream->rbuffer.base)
free (stream->rbuffer.base);
......@@ -815,6 +815,15 @@ mu_stream_set_flags (mu_stream_t stream, int fl)
}
int
mu_stream_clr_flags (mu_stream_t stream, int fl)
{
if (stream == NULL)
return EINVAL;
stream->flags &= ~fl;
return 0;
}
int
mu_stream_set_strerror (mu_stream_t stream,
int (*fp) (mu_stream_t, const char **), void *owner)
{
......