Skip to content

Commit b2dd3a2

Browse files
Disallow null pointer in data field of String
We assume the array field of Strings to be non-null. This is related to issue diffblue/test-gen#317
1 parent 671193c commit b2dd3a2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/java_bytecode/java_object_factory.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,17 @@ void java_object_factoryt::gen_nondet_init(
418418
create_dynamic_objects,
419419
NO_UPDATE_IN_PLACE);
420420

421-
if(assume_non_null)
421+
// Determine whether the pointer can be null.
422+
// In particular the array field of a String should not be null.
423+
bool not_null=
424+
assume_non_null ||
425+
((class_identifier=="java.lang.String" ||
426+
class_identifier=="java.lang.StringBuilder" ||
427+
class_identifier=="java.lang.StringBuffer" ||
428+
class_identifier=="java.lang.CharSequence") &&
429+
subtype.id()==ID_array);
430+
431+
if(not_null)
422432
{
423433
// Add the following code to assignments:
424434
// <expr> = <aoe>;

0 commit comments

Comments
 (0)