Skip to content

Commit 8a9ab0c

Browse files
authored
Merge pull request #6768 from tautschnig/bugfixes/goto_rw-large-object
goto_rw/range_spect: gracefully handle arbitrarily large ranges
2 parents 22999aa + f2f218e commit 8a9ab0c

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
main.c
3+
--full-slice
4+
^\[main\.assertion\.\d+\] line 9 assertion havoc_slice W_OK.*: FAILURE$
5+
^\[main\.assertion\.\d+\] line 13 assertion havoc_slice W_OK.*: FAILURE$
6+
^\[main\.assertion\.\d+\] line 18 assertion havoc_slice W_OK.*: FAILURE$
7+
^\[main\.assertion\.\d+\] line 21 assertion havoc_slice W_OK.*: FAILURE$
8+
^\[main\.assertion\.\d+\] line 24 assertion havoc_slice W_OK.*: FAILURE$
9+
^\[main\.assertion\.\d+\] line 27 assertion havoc_slice W_OK.*: FAILURE$
10+
^\[main\.assertion\.\d+\] line 30 assertion havoc_slice W_OK.*: FAILURE$
11+
\*\* 7 of [0-9]+ failed \(.*\)
12+
^VERIFICATION FAILED$
13+
^EXIT=10$
14+
^SIGNAL=0$
15+
--

src/analyses/goto_rw.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,20 @@ class range_spect
7878

7979
static range_spect to_range_spect(const mp_integer &size)
8080
{
81-
PRECONDITION(size.is_long());
81+
// The size need not fit into the analysis platform's width of a signed long
82+
// (as an example, it could be an unsigned size_t max, or perhaps the source
83+
// platform has much wider types than the analysis platform.
84+
if(!size.is_long())
85+
return range_spect::unknown();
86+
8287
mp_integer::llong_t ll = size.to_long();
83-
CHECK_RETURN(ll <= std::numeric_limits<range_spect::value_type>::max());
84-
CHECK_RETURN(ll >= std::numeric_limits<range_spect::value_type>::min());
88+
if(
89+
ll > std::numeric_limits<range_spect::value_type>::max() ||
90+
ll < std::numeric_limits<range_spect::value_type>::min())
91+
{
92+
return range_spect::unknown();
93+
}
94+
8595
return range_spect{(value_type)ll};
8696
}
8797

0 commit comments

Comments
 (0)