mirror of
https://github.com/Z3Prover/z3
synced 2026-03-20 11:55:49 +00:00
Fix API bugs exercised by test/deep_api_bugs.cpp
- api_fpa.cpp: add RETURN_Z3(nullptr) after SET_ERROR_CODE in Z3_mk_fpa_sort to prevent fall-through to mk_float_sort with invalid params - api_seq.cpp: add null check for str in Z3_mk_string; add null check for str when sz>0 in Z3_mk_lstring; add lo<=hi validation in Z3_mk_re_loop - api_array.cpp: add explicit n==0 validation in Z3_mk_array_sort_n - api_solver.cpp: rename local variable 'c' to avoid shadowing Z3_context param in Z3_solver_propagate_created/decide/on_binding; move init_solver call inside file-exists branches of Z3_solver_from_file - api_ast.cpp: add null check for target in Z3_translate; add null check for _from/_to arrays when num_exprs>0 in Z3_substitute - api_model.cpp: add CHECK_NON_NULL(m) in Z3_add_func_interp; add CHECK_NON_NULL(a) in Z3_model_get_const_interp; add null check for target in Z3_model_translate - api_opt.cpp: add null check for weight string in Z3_optimize_assert_soft - api_quant.cpp: add num_patterns==0 validation in Z3_mk_pattern Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
e6c082e6e8
commit
f413a24408
8 changed files with 48 additions and 8 deletions
|
|
@ -898,6 +898,10 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
expr * a = to_expr(_a);
|
||||
if (num_exprs > 0 && (!_from || !_to)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG, "null from/to arrays with non-zero num_exprs");
|
||||
RETURN_Z3(of_expr(nullptr));
|
||||
}
|
||||
expr * const * from = to_exprs(num_exprs, _from);
|
||||
expr * const * to = to_exprs(num_exprs, _to);
|
||||
expr * r = nullptr;
|
||||
|
|
@ -1514,6 +1518,10 @@ extern "C" {
|
|||
LOG_Z3_translate(c, a, target);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_VALID_AST(a, nullptr);
|
||||
if (!target) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG, "null target context");
|
||||
RETURN_Z3(nullptr);
|
||||
}
|
||||
if (c == target) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
|
||||
RETURN_Z3(nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue