]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Allow flushing ostream multiple times.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 11 Jul 2016 17:27:48 +0000 (20:27 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 4 Aug 2016 15:07:30 +0000 (18:07 +0300)
The first time flushes the encryption and the following times just flush the
parent stream.

src/lib-dcrypt/ostream-encrypt.c

index a18fc2bc38886eda3510c6b556cdbb3d6c8e0e2b..aca819eb9359cab79660b2901126e85f2fc803c9 100644 (file)
@@ -492,7 +492,11 @@ int o_stream_encrypt_flush(struct ostream_private *stream)
        /* if nothing was written, we are done */
        if (!estream->prefix_written) return o_stream_flush(stream->parent);
 
-       i_assert(!estream->finalized);
+       if (estream->finalized) {
+               /* we've already flushed the encrypted output.
+                  just flush the parent. */
+               return o_stream_flush(stream->parent);
+       }
        estream->finalized = TRUE;
 
        /* acquire last block */