summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-04-24 11:36:51 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-04-24 11:36:51 -0400
commit4a802da8d598c6fe3317e186b64a0b020cc96f01 (patch)
tree93f66529a379ff537752cd25d730d0d82e8450f6
parent03220724981ab4e4e2be239b65dec440f008f7da (diff)
downloadbfs-4a802da8d598c6fe3317e186b64a0b020cc96f01.tar.xz
opt: Add missing NULL check in visit_shallow()
visit_shallow() should propagate NULL, but look_up_visitor() dereferences expr to know which visitor to return.
-rw-r--r--src/opt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/opt.c b/src/opt.c
index ffc795b..883d598 100644
--- a/src/opt.c
+++ b/src/opt.c
@@ -947,8 +947,12 @@ static struct bfs_expr *visit_shallow(struct bfs_opt *opt, struct bfs_expr *expr
expr = general(opt, expr, visitor);
}
+ if (!expr) {
+ return NULL;
+ }
+
visit_fn *specific = look_up_visitor(expr, visitor->table);
- if (expr && specific) {
+ if (specific) {
expr = specific(opt, expr, visitor);
}