diff --git a/src/rules/events.c b/src/rules/events.c index 25d62c7..ae5f1f1 100644 --- a/src/rules/events.c +++ b/src/rules/events.c @@ -601,7 +601,7 @@ static unsigned int reduceExpressionSequence(ruleset *tree, messageObject, context, targetProperty)); - ++*i; + ++*i; // increment to next expression makes currentExpression invalid } if (targetProperty->type != JSON_BOOL) { @@ -609,10 +609,12 @@ static unsigned int reduceExpressionSequence(ruleset *tree, } - if ((operator == OP_AND && !targetProperty->value.b) || - (operator == OP_OR && targetProperty->value.b)) { - while (currentExpression->operator != OP_END) { - ++*i; + if ((((operator == OP_AND) && !targetProperty->value.b) || + ((operator == OP_OR) && targetProperty->value.b)) + && (*i < exprs->length)) { + // after reduceExpression() index i moved on to next currentExpression + currentExpression = &exprs->expressions[*i]; + while ((currentExpression->operator != OP_END) && (++*i < exprs->length)) { currentExpression = &exprs->expressions[*i]; } return RULES_OK;