From c752483abb631cdd47f1b95b705944b519ab1678 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Fri, 4 Jan 2008 00:45:32 +0100
Subject: [PATCH] Fixed segfault occuring when command did not exist.

---
 src/lib-sieve/sieve-validator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c
index dd5921a30..c6bbff2ee 100644
--- a/src/lib-sieve/sieve-validator.c
+++ b/src/lib-sieve/sieve-validator.c
@@ -750,7 +750,6 @@ static bool sieve_validate_command
 	enum sieve_ast_type ast_type = sieve_ast_node_type(cmd_node);
 	bool result = TRUE;
 	struct sieve_command_registration *cmd_reg;
-	const struct sieve_command *command;
 	
 	i_assert( ast_type == SAT_TEST || ast_type == SAT_COMMAND );
 	
@@ -758,9 +757,10 @@ static bool sieve_validate_command
 	
 	cmd_reg = sieve_validator_find_command_registration
 		(validator, cmd_node->identifier);
-	command = cmd_reg->command;
 	
-	if ( command != NULL ) {
+	if ( cmd_reg != NULL && cmd_reg->command != NULL ) {
+		const struct sieve_command *command = cmd_reg->command;
+
 		/* Identifier = "" when the command was previously marked as unknown */
 		if ( *(command->identifier) != '\0' ) {
 			if ( (command->type == SCT_COMMAND && ast_type == SAT_TEST) || 
-- 
GitLab