dovecot-2.1-pigeonhole: lib-sieve: fixed cleanup bug in dict scr...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sun Apr 22 18:16:14 EEST 2012


details:   http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/2ff0a5c5c892
changeset: 1614:2ff0a5c5c892
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun Apr 22 17:16:08 2012 +0200
description:
lib-sieve: fixed cleanup bug in dict script implementation.

diffstat:

 src/lib-sieve/sieve-script-dict.c |   2 ++
 src/lib-sieve/sieve-script.c      |  18 +++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (84 lines):

diff -r d07dad1ad41c -r 2ff0a5c5c892 src/lib-sieve/sieve-script-dict.c
--- a/src/lib-sieve/sieve-script-dict.c	Sun Apr 22 15:36:06 2012 +0200
+++ b/src/lib-sieve/sieve-script-dict.c	Sun Apr 22 17:16:08 2012 +0200
@@ -110,6 +110,7 @@
 			"sieve dict backend: failed to initialize dict with data `%s' "
 			"for user `%s'", data, username);
 		*error_r = SIEVE_ERROR_TEMP_FAIL;
+		dict_deinit(&script->dict);
 		return -1;
 	}
 
@@ -131,6 +132,7 @@
 			*error_r = SIEVE_ERROR_NOT_FOUND;
 		}
 
+		dict_deinit(&script->dict);
 		return -1;
 	}
 
diff -r d07dad1ad41c -r 2ff0a5c5c892 src/lib-sieve/sieve-script.c
--- a/src/lib-sieve/sieve-script.c	Sun Apr 22 15:36:06 2012 +0200
+++ b/src/lib-sieve/sieve-script.c	Sun Apr 22 17:16:08 2012 +0200
@@ -195,6 +195,7 @@
 	script->script_class = script_class;
 	script->refcount = 1;
 	script->svinst = svinst;
+
 	script->ehandler = ehandler;
 	
 	script->name = p_strdup_empty(script->pool, name);
@@ -205,7 +206,6 @@
 			"failed to access sieve script", "failed to parse script location: %s",
 			parse_error);
 		*error_r = SIEVE_ERROR_TEMP_FAIL;
-		pool_unref(&script->pool);
 		return NULL;
 	}
 
@@ -217,15 +217,12 @@
 		} else {
 			*error_r = error;
 		}
-
-		pool_unref(&script->pool);
 		return NULL;
 	}
 
 	i_assert( script->location != NULL );
 
 	sieve_error_handler_ref(ehandler);
-
 	return script;
 }
 
@@ -265,8 +262,13 @@
 	}
 
 	script = script_class->v.alloc();
-	return sieve_script_init
-		(script, svinst, script_class, data, name, ehandler, error_r);
+	if ( sieve_script_init
+		(script, svinst, script_class, data, name, ehandler, error_r) == NULL ) {
+		pool_unref(&script->pool);
+		return NULL;
+	}
+
+	return script;
 }
 
 struct sieve_script *sieve_script_create_as
@@ -301,10 +303,12 @@
 	if ( script->stream != NULL )
 		i_stream_unref(&script->stream);
 
-	sieve_error_handler_unref(&script->ehandler);
+	if ( script->ehandler != NULL )
+		sieve_error_handler_unref(&script->ehandler);
 
 	if ( script->v.destroy != NULL )
 		script->v.destroy(script);
+
 	pool_unref(&script->pool);
 	*_script = NULL;
 }


More information about the dovecot-cvs mailing list