diff --git a/src/lib-sieve/plugins/include/ext-include-common.c b/src/lib-sieve/plugins/include/ext-include-common.c index 8de2275fbc14e40550e91beb7dd91fcad24df247..f9eac908c8704da14347059fabff2d9a9de0da09 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.c +++ b/src/lib-sieve/plugins/include/ext-include-common.c @@ -159,8 +159,10 @@ ext_include_get_script_storage(const struct sieve_extension *ext, return NULL; } if (ctx->global_storage == NULL) { - ctx->global_storage = sieve_storage_create( - svinst, ctx->global_location, 0, error_code_r); + if (sieve_storage_create(svinst, ctx->global_location, + 0, &ctx->global_storage, + error_code_r) < 0) + return NULL; } return ctx->global_storage; default: diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c index 3c5c471cccfd80ecad17f1c7135ad8305c3fd409..a77d8658d6bb071a5e799ba1072553ee9c8b6271 100644 --- a/src/lib-sieve/sieve-script.c +++ b/src/lib-sieve/sieve-script.c @@ -127,8 +127,8 @@ int sieve_script_create(struct sieve_instance *svinst, else error_code_r = &error_code; - storage = sieve_storage_create(svinst, location, 0, error_code_r); - if (storage == NULL) + if (sieve_storage_create(svinst, location, 0, + &storage, error_code_r) < 0) return -1; script = sieve_storage_get_script(storage, name, error_code_r); @@ -880,8 +880,8 @@ sieve_script_sequence_create(struct sieve_instance *svinst, else error_code_r = &error_code; - storage = sieve_storage_create(svinst, location, 0, error_code_r); - if (storage == NULL) + if (sieve_storage_create(svinst, location, 0, + &storage, error_code_r) < 0) return NULL; sseq = sieve_storage_get_script_sequence(storage, error_code_r); diff --git a/src/lib-sieve/sieve-storage.c b/src/lib-sieve/sieve-storage.c index b71a1af2d685fc702fb125c0d3364bd83cbaee5e..a6899e6fd56b6a563949de9086610fc3538a677e 100644 --- a/src/lib-sieve/sieve-storage.c +++ b/src/lib-sieve/sieve-storage.c @@ -363,10 +363,10 @@ sieve_storage_init(struct sieve_instance *svinst, return 0; } -struct sieve_storage * -sieve_storage_create(struct sieve_instance *svinst, const char *location, - enum sieve_storage_flags flags, - enum sieve_error *error_code_r) +int sieve_storage_create(struct sieve_instance *svinst, const char *location, + enum sieve_storage_flags flags, + struct sieve_storage **storage_r, + enum sieve_error *error_code_r) { const struct sieve_storage *storage_class; enum sieve_error error_code; @@ -376,6 +376,7 @@ sieve_storage_create(struct sieve_instance *svinst, const char *location, /* Dont use this function for creating a synchronizing storage */ i_assert((flags & SIEVE_STORAGE_FLAG_SYNCHRONIZING) == 0); + *storage_r = NULL; if (error_code_r != NULL) *error_code_r = SIEVE_ERROR_NONE; else @@ -385,18 +386,14 @@ sieve_storage_create(struct sieve_instance *svinst, const char *location, if ((ret = sieve_storage_driver_parse(svinst, &data, &storage_class)) < 0) { *error_code_r = SIEVE_ERROR_TEMP_FAILURE; - return NULL; + return -1; } if (ret == 0) storage_class = &sieve_file_storage; - struct sieve_storage *storage; - - if (sieve_storage_init(svinst, storage_class, data, flags, FALSE, - &storage, error_code_r) < 0) - return NULL; - return storage; + return sieve_storage_init(svinst, storage_class, data, flags, FALSE, + storage_r, error_code_r); } static struct sieve_storage * @@ -547,9 +544,8 @@ sieve_storage_create_personal(struct sieve_instance *svinst, "Trying default script location '%s'", set_default); - storage = sieve_storage_create(svinst, set_default, 0, - error_code_r); - if (storage == NULL) { + if (sieve_storage_create(svinst, set_default, 0, + &storage, error_code_r) < 0) { switch (*error_code_r) { case SIEVE_ERROR_NOT_FOUND: e_debug(svinst->event, "storage: " diff --git a/src/lib-sieve/sieve-storage.h b/src/lib-sieve/sieve-storage.h index f766587ebd7f725f4c46c3b6c4f65697ebfe9fe0..4714f20655fd3e62c6fc9ceed00e360c851423d3 100644 --- a/src/lib-sieve/sieve-storage.h +++ b/src/lib-sieve/sieve-storage.h @@ -25,10 +25,10 @@ enum sieve_storage_flags { struct sieve_storage; -struct sieve_storage * -sieve_storage_create(struct sieve_instance *svinst, const char *location, - enum sieve_storage_flags flags, - enum sieve_error *error_code_r); +int sieve_storage_create(struct sieve_instance *svinst, const char *location, + enum sieve_storage_flags flags, + struct sieve_storage **storage_r, + enum sieve_error *error_code_r); struct sieve_storage * sieve_storage_create_personal(struct sieve_instance *svinst, struct mail_user *user, diff --git a/src/plugins/imap-filter-sieve/imap-filter-sieve.c b/src/plugins/imap-filter-sieve/imap-filter-sieve.c index 95bd45fa21d8edee5f66ed90eee522b94fbe9cd4..67a2eac6f0d1e0cc89fd4780e2759d0e7d2aa5af 100644 --- a/src/plugins/imap-filter-sieve/imap-filter-sieve.c +++ b/src/plugins/imap-filter-sieve/imap-filter-sieve.c @@ -253,9 +253,8 @@ imap_filter_sieve_get_global_storage(struct imap_filter_sieve_context *sctx, *error_r = "No global Sieve scripts available"; return -1; } - ifsuser->global_storage = - sieve_storage_create(svinst, location, 0, &error_code); - if (ifsuser->global_storage != NULL) { + if (sieve_storage_create(svinst, location, 0, + &ifsuser->global_storage, &error_code) == 0) { *storage_r = ifsuser->global_storage; return 0; }