File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
regression/cbmc-library/calloc-02 Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,10 @@ int main()
6
6
char * p = calloc (-1 , -1 );
7
7
if (p )
8
8
assert (p [0 ] == 0 );
9
+
10
+ size_t size ;
11
+ size_t num ;
12
+ p = calloc (size , num );
13
+ if (p && size > 0 && num > 0 )
14
+ assert (p [0 ] == 0 );
9
15
}
Original file line number Diff line number Diff line change @@ -132,7 +132,8 @@ optionalt<exprt> expr_initializert<nondet>::expr_initializer_rec(
132
132
if (!tmpval.has_value ())
133
133
return {};
134
134
135
- if (array_type.size ().id ()==ID_infinity)
135
+ const auto array_size = numeric_cast<mp_integer>(array_type.size ());
136
+ if (array_type.size ().id () == ID_infinity || !array_size.has_value ())
136
137
{
137
138
if (nondet)
138
139
return side_effect_expr_nondett (type, source_location);
@@ -142,15 +143,6 @@ optionalt<exprt> expr_initializert<nondet>::expr_initializer_rec(
142
143
return std::move (value);
143
144
}
144
145
145
- const auto array_size = numeric_cast<mp_integer>(array_type.size ());
146
- if (!array_size.has_value ())
147
- {
148
- if (nondet)
149
- return side_effect_expr_nondett (type, source_location);
150
- else
151
- return {};
152
- }
153
-
154
146
if (*array_size < 0 )
155
147
return {};
156
148
You can’t perform that action at this time.
0 commit comments