Skip to content

Commit 41003e8

Browse files
committed
Handle negative byte_extract offsets
These are just out-of-bounds accesses.
1 parent efea5c4 commit 41003e8

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/solvers/flattening/boolbv_byte_extract.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,14 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
133133

134134
if(index.has_value())
135135
{
136-
if(*index < 0)
137-
throw "byte_extract flatting with negative offset: "+expr.pretty();
138-
139136
const mp_integer offset = *index * byte_width;
140137

141-
std::size_t offset_i=integer2unsigned(offset);
142-
143138
for(std::size_t i=0; i<width; i++)
144139
// out of bounds?
145-
if(offset<0 || offset_i+i>=op_bv.size())
140+
if(offset + i < 0 || offset + i >= op_bv.size())
146141
bv[i]=prop.new_variable();
147142
else
148-
bv[i]=op_bv[offset_i+i];
143+
bv[i] = op_bv[numeric_cast_v<std::size_t>(offset) + i];
149144
}
150145
else
151146
{

0 commit comments

Comments
 (0)