diff mbox series

[ovs-dev,v2,2/3] expr: Avoid crash if all sub-expressions crushed down to 'true'.

Message ID 20230320103809.3121679-3-i.maximets@ovn.org
State Changes Requested
Headers show
Series expr: Optimize OR expressions. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ilya Maximets March 20, 2023, 10:38 a.m. UTC
expr_sort() can potentially return NULL if all sub-expressions got
crushed into 'true'.  This didn't happen before, but can happen
with more aggressive optimizations in crush_or().

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 lib/expr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/expr.c b/lib/expr.c
index f9f3b6991..d881e07f7 100644
--- a/lib/expr.c
+++ b/lib/expr.c
@@ -2879,7 +2879,7 @@  expr_sort(struct expr *expr)
     }
     free(subs);
 
-    return expr;
+    return expr ? expr : expr_create_boolean(true);
 }
 
 static struct expr *expr_normalize_or(struct expr *expr);