@@ -55,6 +55,8 @@ class goto_check_ct
5555 enable_bounds_check = _options.get_bool_option (" bounds-check" );
5656 enable_pointer_check = _options.get_bool_option (" pointer-check" );
5757 enable_memory_leak_check = _options.get_bool_option (" memory-leak-check" );
58+ enable_memory_cleanup_check =
59+ _options.get_bool_option (" memory-cleanup-check" );
5860 enable_div_by_zero_check = _options.get_bool_option (" div-by-zero-check" );
5961 enable_enum_range_check = _options.get_bool_option (" enum-range-check" );
6062 enable_signed_overflow_check =
@@ -257,6 +259,7 @@ class goto_check_ct
257259 bool enable_bounds_check;
258260 bool enable_pointer_check;
259261 bool enable_memory_leak_check;
262+ bool enable_memory_cleanup_check;
260263 bool enable_div_by_zero_check;
261264 bool enable_enum_range_check;
262265 bool enable_signed_overflow_check;
@@ -276,6 +279,7 @@ class goto_check_ct
276279 {" bounds-check" , &enable_bounds_check},
277280 {" pointer-check" , &enable_pointer_check},
278281 {" memory-leak-check" , &enable_memory_leak_check},
282+ {" memory-cleanup-check" , &enable_memory_cleanup_check},
279283 {" div-by-zero-check" , &enable_div_by_zero_check},
280284 {" enum-range-check" , &enable_enum_range_check},
281285 {" signed-overflow-check" , &enable_signed_overflow_check},
@@ -2219,6 +2223,19 @@ void goto_check_ct::goto_check(
22192223 // this has no successor
22202224 assertions.clear ();
22212225 }
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+ }
22222239 else if (i.is_dead ())
22232240 {
22242241 if (enable_pointer_check || enable_pointer_primitive_check)
0 commit comments