]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
ostream: Mark stream closed before handling its callback to avoid infinite loops.
authorTimo Sirainen <tss@iki.fi>
Sun, 3 Nov 2013 21:27:15 +0000 (23:27 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 3 Nov 2013 21:27:15 +0000 (23:27 +0200)
The callback could call o_stream_copy_error_from_parent(), which in turn
would try to close the same ostream again.

src/lib/ostream.c

index de58b2f1ad4e264034e582c3190c38c80d664a1b..73456aa66a254d47a1633fcdd24fed8f9eeab76c 100644 (file)
@@ -46,8 +46,8 @@ const char *o_stream_get_error(struct ostream *stream)
 static void o_stream_close_full(struct ostream *stream, bool close_parents)
 {
        if (!stream->closed) {
-               io_stream_close(&stream->real_stream->iostream, close_parents);
                stream->closed = TRUE;
+               io_stream_close(&stream->real_stream->iostream, close_parents);
        }
 
        if (stream->stream_errno == 0)