]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: If fs_default_copy() fails, close the copy stream immediately.
authorTimo Sirainen <tss@iki.fi>
Sat, 1 Jun 2013 14:08:19 +0000 (17:08 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 1 Jun 2013 14:08:19 +0000 (17:08 +0300)
The stream's origin may already be freed by the time the fs_file_close() is
trying to close the stream.

src/lib-fs/fs-api.c

index 9b1d633f57644c1d7f7a526f5e8ce2ed8e787ac4..73f4d3d02d5b0598ffbed97d93ebf2de1b8ee15c 100644 (file)
@@ -552,12 +552,16 @@ int fs_default_copy(struct fs_file *src, struct fs_file *dest)
                errno = dest->copy_input->stream_errno;
                fs_set_error(dest->fs, "read(%s) failed: %m",
                             i_stream_get_name(dest->copy_input));
+               i_stream_unref(&dest->copy_input);
+               fs_write_stream_abort(dest, &dest->copy_output);
                return -1;
        }
        if (dest->copy_output->stream_errno != 0) {
                errno = dest->copy_output->stream_errno;
                fs_set_error(dest->fs, "write(%s) failed: %m",
                             o_stream_get_name(dest->copy_output));
+               i_stream_unref(&dest->copy_input);
+               fs_write_stream_abort(dest, &dest->copy_output);
                return -1;
        }
        if (!dest->copy_input->eof) {