3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-11-27 15:59:50 +00:00

Add check that argument of Z3_is_algebraic_number is_expr (#8027)

To make sure that the `to_expr` cast is safe.

Signed-off-by: Josh Berdine <josh@berdine.net>
This commit is contained in:
Josh Berdine 2025-11-16 00:19:39 +00:00 committed by GitHub
parent 6d19c045d8
commit 43525481f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,8 +156,15 @@ extern "C" {
}
bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_algebraic_number(c, a);
RESET_ERROR_CODE();
if (!is_expr(a)) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return false;
}
return mk_c(c)->autil().is_irrational_algebraic_numeral(to_expr(a));
Z3_CATCH_RETURN(false);
}
Z3_ast Z3_API Z3_get_algebraic_number_lower(Z3_context c, Z3_ast a, unsigned precision) {