lang: ast: fix nullptr deref in expr_finalise_arith when calculating ast node bounds

This commit is contained in:
2025-05-12 15:53:06 +01:00
parent 7580b714f0
commit d746ea5234

View File

@@ -379,18 +379,28 @@ enum ivy_status expr_finalise_arith(
op = op_node->n_op;
tmp = b_queue_pop_back(&q);
op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry);
op_node->n_right->n_parent = (struct ivy_ast_node *)op_node;
ivy_ast_node_extend_bounds_recursive(
(struct ivy_ast_node *)op_node, (struct ivy_ast_node *)tmp);
if (op_node->n_right) {
op_node->n_right->n_parent = (struct ivy_ast_node *)op_node;
ivy_ast_node_extend_bounds_recursive(
(struct ivy_ast_node *)op_node,
(struct ivy_ast_node *)tmp);
}
if (op->op_arity == IVY_OP_BINARY) {
tmp = b_queue_pop_back(&q);
op_node->n_left
= b_unbox(struct ivy_ast_node, tmp, n_entry);
op_node->n_left->n_parent = (struct ivy_ast_node *)op_node;
ivy_ast_node_extend_bounds_recursive(
(struct ivy_ast_node *)op_node,
(struct ivy_ast_node *)tmp);
if (op_node->n_left) {
op_node->n_left->n_parent
= (struct ivy_ast_node *)op_node;
ivy_ast_node_extend_bounds_recursive(
(struct ivy_ast_node *)op_node,
(struct ivy_ast_node *)tmp);
}
}
/* ...and push the newly-completed operator node to the operand