From 6dc92ae9d5e3797dacd3de03e26629a0b71da2b3 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sun, 11 Sep 2011 00:19:07 +0200 Subject: [PATCH] variables extension: fixed segfault bug triggered when dumping binary variable scopes. --- .../plugins/include/ext-include-common.c | 2 +- .../plugins/variables/ext-variables-common.c | 18 ++++++++++-------- .../plugins/variables/ext-variables-dump.c | 3 ++- .../plugins/variables/sieve-ext-variables.h | 4 ++-- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/lib-sieve/plugins/include/ext-include-common.c b/src/lib-sieve/plugins/include/ext-include-common.c index 2b027e592..56c96a1d7 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.c +++ b/src/lib-sieve/plugins/include/ext-include-common.c @@ -164,7 +164,7 @@ struct ext_include_ast_context *ext_include_create_ast_context sieve_variable_scope_ref(actx->global_vars); } else { - actx->global_vars = sieve_variable_scope_create(this_ext); + actx->global_vars = sieve_variable_scope_create(this_ext->svinst, this_ext); } sieve_ast_extension_register diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.c b/src/lib-sieve/plugins/variables/ext-variables-common.c index 8140ebca9..70ae54614 100644 --- a/src/lib-sieve/plugins/variables/ext-variables-common.c +++ b/src/lib-sieve/plugins/variables/ext-variables-common.c @@ -42,10 +42,11 @@ struct sieve_variable_scope { pool_t pool; int refcount; - struct sieve_variable *error_var; - + struct sieve_instance *svinst; const struct sieve_extension *ext; + struct sieve_variable *error_var; + struct hash_table *variables; ARRAY_DEFINE(variable_index, struct sieve_variable *); }; @@ -64,7 +65,7 @@ struct sieve_variable_scope_iter { }; struct sieve_variable_scope *sieve_variable_scope_create -(const struct sieve_extension *ext) +(struct sieve_instance *svinst, const struct sieve_extension *ext) { struct sieve_variable_scope *scope; pool_t pool; @@ -74,6 +75,7 @@ struct sieve_variable_scope *sieve_variable_scope_create scope->pool = pool; scope->refcount = 1; + scope->svinst = svinst; scope->ext = ext; scope->variables = hash_table_create @@ -234,7 +236,7 @@ struct sieve_variable *sieve_variable_scope_get_indexed /* Scope binary */ struct sieve_variable_scope *sieve_variable_scope_binary_dump -(const struct sieve_extension *ext, +(struct sieve_instance *svinst, const struct sieve_extension *ext, const struct sieve_dumptime_env *denv, sieve_size_t *address) { struct sieve_variable_scope *local_scope; @@ -253,7 +255,7 @@ struct sieve_variable_scope *sieve_variable_scope_binary_dump return FALSE; /* Create scope */ - local_scope = sieve_variable_scope_create(ext); + local_scope = sieve_variable_scope_create(svinst, ext); /* Read and dump scope itself */ @@ -336,7 +338,7 @@ struct sieve_variable_scope_binary *sieve_variable_scope_binary_read } /* Create scope */ - scope = sieve_variable_scope_create(ext); + scope = sieve_variable_scope_create(svinst, ext); scpbin = sieve_variable_scope_binary_create(scope); scpbin->size = scope_size; @@ -352,7 +354,7 @@ struct sieve_variable_scope *sieve_variable_scope_binary_get (struct sieve_variable_scope_binary *scpbin) { const struct sieve_extension *ext = scpbin->scope->ext; - struct sieve_instance *svinst = ext->svinst; + struct sieve_instance *svinst = scpbin->scope->svinst; const char *ext_name = ( ext == NULL ? "variables" : sieve_extension_name(ext) ); unsigned int i; @@ -551,7 +553,7 @@ static struct sieve_variable_scope *ext_variables_create_local_scope { struct sieve_variable_scope *scope; - scope = sieve_variable_scope_create(NULL); + scope = sieve_variable_scope_create(this_ext->svinst, NULL); sieve_ast_extension_register (ast, this_ext, &variables_ast_extension, (void *) scope); diff --git a/src/lib-sieve/plugins/variables/ext-variables-dump.c b/src/lib-sieve/plugins/variables/ext-variables-dump.c index a102dd3e9..d91cc0469 100644 --- a/src/lib-sieve/plugins/variables/ext-variables-dump.c +++ b/src/lib-sieve/plugins/variables/ext-variables-dump.c @@ -73,7 +73,8 @@ bool ext_variables_code_dump struct ext_variables_dump_context *dctx; struct sieve_variable_scope *local_scope; - local_scope = sieve_variable_scope_binary_dump(NULL, denv, address); + local_scope = sieve_variable_scope_binary_dump + (ext->svinst, NULL, denv, address); dctx = ext_variables_dump_get_context(ext, denv); dctx->local_scope = local_scope; diff --git a/src/lib-sieve/plugins/variables/sieve-ext-variables.h b/src/lib-sieve/plugins/variables/sieve-ext-variables.h index 5258e04ad..0365dd5c5 100644 --- a/src/lib-sieve/plugins/variables/sieve-ext-variables.h +++ b/src/lib-sieve/plugins/variables/sieve-ext-variables.h @@ -63,7 +63,7 @@ struct sieve_variable { struct sieve_variable_scope; struct sieve_variable_scope *sieve_variable_scope_create - (const struct sieve_extension *ext); + (struct sieve_instance *svinst, const struct sieve_extension *ext); void sieve_variable_scope_ref (struct sieve_variable_scope *scope); void sieve_variable_scope_unref @@ -91,7 +91,7 @@ void sieve_variable_scope_binary_unref (struct sieve_variable_scope_binary **scpbin); struct sieve_variable_scope *sieve_variable_scope_binary_dump - (const struct sieve_extension *ext, + (struct sieve_instance *svinst, const struct sieve_extension *ext, const struct sieve_dumptime_env *denv, sieve_size_t *address); struct sieve_variable_scope_binary *sieve_variable_scope_binary_read (struct sieve_instance *svinst, const struct sieve_extension *ext, -- GitLab