@@ -55,6 +55,8 @@ class goto_check_ct
55
55
enable_bounds_check = _options.get_bool_option (" bounds-check" );
56
56
enable_pointer_check = _options.get_bool_option (" pointer-check" );
57
57
enable_memory_leak_check = _options.get_bool_option (" memory-leak-check" );
58
+ enable_memory_cleanup_check =
59
+ _options.get_bool_option (" memory-cleanup-check" );
58
60
enable_div_by_zero_check = _options.get_bool_option (" div-by-zero-check" );
59
61
enable_enum_range_check = _options.get_bool_option (" enum-range-check" );
60
62
enable_signed_overflow_check =
@@ -257,6 +259,7 @@ class goto_check_ct
257
259
bool enable_bounds_check;
258
260
bool enable_pointer_check;
259
261
bool enable_memory_leak_check;
262
+ bool enable_memory_cleanup_check;
260
263
bool enable_div_by_zero_check;
261
264
bool enable_enum_range_check;
262
265
bool enable_signed_overflow_check;
@@ -276,6 +279,7 @@ class goto_check_ct
276
279
{" bounds-check" , &enable_bounds_check},
277
280
{" pointer-check" , &enable_pointer_check},
278
281
{" memory-leak-check" , &enable_memory_leak_check},
282
+ {" memory-cleanup-check" , &enable_memory_cleanup_check},
279
283
{" div-by-zero-check" , &enable_div_by_zero_check},
280
284
{" enum-range-check" , &enable_enum_range_check},
281
285
{" signed-overflow-check" , &enable_signed_overflow_check},
@@ -2219,6 +2223,19 @@ void goto_check_ct::goto_check(
2219
2223
// this has no successor
2220
2224
assertions.clear ();
2221
2225
}
2226
+ else if (i.is_assume ())
2227
+ {
2228
+ // These are further 'exit points' of the program
2229
+ const exprt simplified_guard = simplify_expr (i.condition (), ns);
2230
+ if (
2231
+ enable_memory_cleanup_check && simplified_guard.is_false () &&
2232
+ (function_identifier == " abort" || function_identifier == " exit" ||
2233
+ function_identifier == " _Exit" ||
2234
+ (i.labels .size () == 1 && i.labels .front () == " __VERIFIER_abort" )))
2235
+ {
2236
+ memory_leak_check (function_identifier);
2237
+ }
2238
+ }
2222
2239
else if (i.is_dead ())
2223
2240
{
2224
2241
if (enable_pointer_check || enable_pointer_primitive_check)
0 commit comments