mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
avoid a crash in maximize_term when the term var has not been used
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
d80f6e3222
commit
f2e878047d
1 changed files with 6 additions and 1 deletions
|
@ -504,7 +504,8 @@ lar_term lar_solver::get_term_to_maximize(unsigned ext_j) const {
|
|||
r. add_monomial(one_of_type<mpq>(), local_j);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!is_term(ext_j) || adjust_term_index(ext_j) >= m_terms.size())
|
||||
return lar_term(); // return an empty term
|
||||
return get_term(ext_j);
|
||||
}
|
||||
|
||||
|
@ -513,6 +514,10 @@ lp_status lar_solver::maximize_term(unsigned ext_j,
|
|||
bool was_feasible = m_mpq_lar_core_solver.m_r_solver.calc_current_x_is_feasible_include_non_basis();
|
||||
impq prev_value;
|
||||
lar_term term = get_term_to_maximize(ext_j);
|
||||
if (term.is_empty()) {
|
||||
return lp_status::UNBOUNDED;
|
||||
}
|
||||
|
||||
auto backup = m_mpq_lar_core_solver.m_r_x;
|
||||
if (was_feasible) {
|
||||
prev_value = term.apply(m_mpq_lar_core_solver.m_r_x);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue