diff mbox series

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

Message ID 20230405194813.548329-3-i.maximets@ovn.org
State Accepted
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 April 5, 2023, 7:48 p.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().

Acked-by: Han Zhou <hzhou@ovn.org>
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 0cf54d486..9659b9b63 100644
--- a/lib/expr.c
+++ b/lib/expr.c
@@ -3003,7 +3003,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);