From 55afd7377d5227a9994e299969b005b797a15ee3 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Tue, 30 Jun 2009 16:57:42 +0200 Subject: [PATCH] If the previous evaluation failed, don't process '!' This catches the case of ((expr1) && !(expr2)), where it would still process expr2 if expr1 failed. --- src/main/evaluate.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/evaluate.c b/src/main/evaluate.c index 0c31b19..35f9ae7 100644 --- a/src/main/evaluate.c +++ b/src/main/evaluate.c @@ -585,8 +585,14 @@ int radius_evaluate_condition(REQUEST *request, int modreturn, int depth, * ! EXPR */ if (!found_condition && (*p == '!')) { - RDEBUG4(">>> INVERT"); - invert = TRUE; + /* + * Don't change the results if we're not + * evaluating the condition. + */ + if (evaluate_next_condition) { + RDEBUG4(">>> INVERT"); + invert = TRUE; + } p++; while ((*p == ' ') || (*p == '\t')) p++; @@ -611,13 +617,13 @@ int radius_evaluate_condition(REQUEST *request, int modreturn, int depth, } if (invert) { - if (evaluate_next_condition) - RDEBUG2("%.*s Converting !%s -> %s", - depth, filler, - (result != FALSE) ? "TRUE" : "FALSE", - (result == FALSE) ? "TRUE" : "FALSE"); - - result = (result == FALSE); + if (evaluate_next_condition) { + RDEBUG2("%.*s Converting !%s -> %s", + depth, filler, + (result != FALSE) ? "TRUE" : "FALSE", + (result == FALSE) ? "TRUE" : "FALSE"); + result = (result == FALSE); + } invert = FALSE; } -- 2.1.4