Skip to content

Commit 00bb9b1

Browse files
authored
Merge pull request #900 from romainbrenguier/pull-request/forbid-null-data-in-string
Disallow null pointer in data field of String
2 parents 5b5a4d2 + b2dd3a2 commit 00bb9b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/java_bytecode/java_object_factory.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,17 @@ void java_object_factoryt::gen_nondet_init(
509509
create_dynamic_objects,
510510
NO_UPDATE_IN_PLACE);
511511

512-
if(assume_non_null)
512+
// Determine whether the pointer can be null.
513+
// In particular the array field of a String should not be null.
514+
bool not_null=
515+
assume_non_null ||
516+
((class_identifier=="java.lang.String" ||
517+
class_identifier=="java.lang.StringBuilder" ||
518+
class_identifier=="java.lang.StringBuffer" ||
519+
class_identifier=="java.lang.CharSequence") &&
520+
subtype.id()==ID_array);
521+
522+
if(not_null)
513523
{
514524
// Add the following code to assignments:
515525
// <expr> = <aoe>;

0 commit comments

Comments
 (0)