dovecot-2.2: fs-sis: Memory leak fix.

dovecot at dovecot.org dovecot at dovecot.org
Thu Dec 19 21:26:01 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/4ba74eca3099
changeset: 17072:4ba74eca3099
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Dec 19 21:25:43 2013 +0200
description:
fs-sis: Memory leak fix.

diffstat:

 src/lib-fs/fs-sis.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r 369d8e994372 -r 4ba74eca3099 src/lib-fs/fs-sis.c
--- a/src/lib-fs/fs-sis.c	Thu Dec 19 21:25:28 2013 +0200
+++ b/src/lib-fs/fs-sis.c	Thu Dec 19 21:25:43 2013 +0200
@@ -359,9 +359,10 @@
 						fs_file_last_error(_file));
 	} else {
 		file->fs_output = fs_write_stream(file->super);
-		if (file->hash_input == NULL)
+		if (file->hash_input == NULL) {
 			_file->output = file->fs_output;
-		else {
+			o_stream_ref(_file->output);
+		} else {
 			/* compare if files are equal */
 			_file->output = o_stream_create_cmp(file->fs_output,
 							    file->hash_input);
@@ -374,22 +375,27 @@
 {
 	struct sis_fs_file *file = (struct sis_fs_file *)_file;
 
+	if (o_stream_nfinish(_file->output) < 0)
+		success = FALSE;
 	if (!success) {
 		if (file->super != NULL) {
 			fs_write_stream_abort(file->super, &file->fs_output);
 			fs_sis_file_copy_error(file);
 		}
+		o_stream_unref(&_file->output);
 		return -1;
 	}
 
 	if (file->hash_input != NULL &&
 	    o_stream_cmp_equals(_file->output) &&
 	    i_stream_is_eof(file->hash_input)) {
+		o_stream_unref(&_file->output);
 		if (fs_sis_try_link(file)) {
 			fs_write_stream_abort(file->super, &file->fs_output);
 			return 1;
 		}
 	}
+	o_stream_unref(&_file->output);
 
 	if (fs_write_stream_finish(file->super, &file->fs_output) < 0) {
 		fs_sis_file_copy_error(file);


More information about the dovecot-cvs mailing list