From 5673ee51bbbea0963da8974b19bd7685eafc08b9 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Tue, 28 Jun 2016 23:17:50 +0200 Subject: [PATCH] lib-sieve: Make static analyzer happier about argument validation. Added assertions. --- src/lib-sieve/plugins/mime/tag-mime.c | 2 ++ src/lib-sieve/plugins/notify/cmd-denotify.c | 2 ++ src/lib-sieve/sieve-validator.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/lib-sieve/plugins/mime/tag-mime.c b/src/lib-sieve/plugins/mime/tag-mime.c index aacd1e5f9..4ab32931c 100644 --- a/src/lib-sieve/plugins/mime/tag-mime.c +++ b/src/lib-sieve/plugins/mime/tag-mime.c @@ -154,6 +154,8 @@ static bool tag_mime_option_validate struct sieve_ast_argument *mime_arg; struct tag_mime_data *data; + i_assert(tag != NULL); + /* Detach tag itself */ *arg = sieve_ast_arguments_detach(*arg,1); diff --git a/src/lib-sieve/plugins/notify/cmd-denotify.c b/src/lib-sieve/plugins/notify/cmd-denotify.c index 7da0b8e2e..e37ec81f3 100644 --- a/src/lib-sieve/plugins/notify/cmd-denotify.c +++ b/src/lib-sieve/plugins/notify/cmd-denotify.c @@ -125,6 +125,8 @@ static bool tag_match_type_validate (struct cmd_denotify_context_data *) cmd->data; struct sieve_ast_argument *tag = *arg; + i_assert(tag != NULL); + if ( !match_type_tag.validate(valdtr, arg, cmd) ) return FALSE; diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c index e6aeaab00..21d993e7d 100644 --- a/src/lib-sieve/sieve-validator.c +++ b/src/lib-sieve/sieve-validator.c @@ -915,6 +915,8 @@ bool sieve_validate_tag_parameter const char *arg_name, unsigned int arg_pos, enum sieve_ast_argument_type req_type, bool constant) { + i_assert(tag != NULL); + if ( param == NULL ) { const char *position = ( arg_pos == 0 ? "" : t_strdup_printf(" %d (%s)", arg_pos, arg_name) ); -- GitLab