Skip to content

Commit c2a8cb0

Browse files
author
Joel Allred
committed
Get length from array_pool in get_array()
Avoid reading from array size.
1 parent 0da5dc9 commit c2a8cb0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/solvers/strings/string_refinement.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,11 @@ static optionalt<exprt> get_array(
965965
const array_string_exprt &arr,
966966
const array_poolt &array_pool)
967967
{
968-
const exprt &size = arr.length();
968+
const auto &size_from_pool = array_pool.get_length_if_exists(arr);
969+
const exprt size = size_from_pool.has_value()
970+
? size_from_pool.value()
971+
: exprt(ID_unknown, arr.length_type());
972+
969973
exprt arr_val = simplify_expr(adjust_if_recursive(super_get(arr), ns), ns);
970974
exprt size_val = super_get(size);
971975
size_val = simplify_expr(size_val, ns);
@@ -991,8 +995,8 @@ static optionalt<exprt> get_array(
991995

992996
if(n > MAX_CONCRETE_STRING_SIZE)
993997
{
994-
stream << "(sr::get_array) long string (size " << format(arr.length())
995-
<< " = " << n << ") " << format(arr) << messaget::eom;
998+
stream << "(sr::get_array) long string (size " << format(size) << " = " << n
999+
<< ") " << format(arr) << messaget::eom;
9961000
stream << "(sr::get_array) consider reducing max-nondet-string-length so "
9971001
"that no string exceeds "
9981002
<< MAX_CONCRETE_STRING_SIZE

0 commit comments

Comments
 (0)