Skip to content

Commit 0151c89

Browse files
author
Thomas Kiley
committed
Special case handling for void* pointers
This ensures they are simply set to null, avoiding a crash (or any strange initlization of memory of an unknown type)
1 parent dc62373 commit 0151c89

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/goto-harness/recursive_initialization.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,17 @@ code_blockt recursive_initializationt::build_pointer_constructor(
623623

624624
code_blockt body{};
625625

626+
// always initalize void* pointers as NULL
627+
if(type.subtype().id() == ID_empty)
628+
{
629+
null_pointer_exprt nullptr_expr{pointer_type(type.subtype())};
630+
code_blockt null_and_return{};
631+
code_assignt assign_null{dereference_exprt{result}, nullptr_expr};
632+
null_and_return.add(assign_null);
633+
null_and_return.add(code_returnt{});
634+
return null_and_return;
635+
}
636+
626637
// build:
627638
// void type_constructor_ptr_T(int depth, T** result)
628639
// {

0 commit comments

Comments
 (0)