dovecot-2.2-pigeonhole: lib-sieve: dict: Fixed memory allocation...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Mar 14 14:32:07 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/adbd9fc695d1
changeset: 2010:adbd9fc695d1
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Mar 14 15:31:53 2015 +0100
description:
lib-sieve: dict: Fixed memory allocation bug in script object.

diffstat:

 src/lib-sieve/storage/dict/sieve-dict-script.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r 38689335cc93 -r adbd9fc695d1 src/lib-sieve/storage/dict/sieve-dict-script.c
--- a/src/lib-sieve/storage/dict/sieve-dict-script.c	Thu Mar 12 22:14:44 2015 +0100
+++ b/src/lib-sieve/storage/dict/sieve-dict-script.c	Sat Mar 14 15:31:53 2015 +0100
@@ -70,7 +70,7 @@
 	struct sieve_dict_storage *dstorage =
 		(struct sieve_dict_storage *)storage;
 	const char *name = script->name;
-	const char *path;
+	const char *path, *data_id;
 	int ret;
 
 	if ( sieve_dict_storage_get_dict
@@ -81,7 +81,7 @@
 		(DICT_SIEVE_NAME_PATH, dict_escape_string(name), NULL);
 
 	ret = dict_lookup
-		(dscript->dict, script->pool, path, &dscript->data_id);
+		(dscript->dict, script->pool, path, &data_id);
 	if ( ret <= 0 ) {
 		if ( ret < 0 ) {
 			sieve_script_set_critical(script,
@@ -98,6 +98,7 @@
 		return -1;
 	}
 
+	dscript->data_id = p_strdup(script->pool, data_id);
 	return 0;
 }
 
@@ -107,7 +108,7 @@
 {
 	struct sieve_dict_script *dscript =
 		(struct sieve_dict_script *)script;
-	const char *path, *name = script->name;
+	const char *path, *name = script->name, *data;
 	int ret;
 
 	dscript->data_pool =
@@ -117,7 +118,7 @@
 		(DICT_SIEVE_DATA_PATH, dict_escape_string(dscript->data_id), NULL);
 
 	ret = dict_lookup
-		(dscript->dict, dscript->data_pool, path, &dscript->data);
+		(dscript->dict, dscript->data_pool, path, &data);
 	if ( ret <= 0 ) {
 		if ( ret < 0 ) {
 			sieve_script_set_critical(script,
@@ -133,7 +134,8 @@
 		*error_r = SIEVE_ERROR_TEMP_FAILURE;
 		return -1;
 	}
-
+	
+	dscript->data = p_strdup(script->pool, data);
 	*stream_r = i_stream_create_from_data(dscript->data, strlen(dscript->data));
 	return 0;
 }


More information about the dovecot-cvs mailing list