Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added regression/jbmc-strings/char_escape/Test.class
Binary file not shown.
19 changes: 19 additions & 0 deletions regression/jbmc-strings/char_escape/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class Test {

public static boolean test(char c1, char c2, char c3, char c4, char c5, char c6, char c7, char c8) {
StringBuilder sb = new StringBuilder("");
sb.append(c1);
sb.append(c2);
sb.append(c3);
sb.append(c4);
sb.append(c5);
sb.append(c6);
sb.append(c7);
sb.append(c8);
if (sb.toString().equals("\b\t\n\f\r\"\'\\"))
return true;
if (!sb.toString().equals("\b\t\n\f\r\"\'\\"))
return false;
return true;
}
}
6 changes: 6 additions & 0 deletions regression/jbmc-strings/char_escape/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CORE
Test.class
--refine-strings --function Test.test --cover location --trace --json-ui
^EXIT=0$
^SIGNAL=0$
20 of 23 covered \(87.0%\)|30 of 44 covered \(68.2%\)
3 changes: 2 additions & 1 deletion src/java_bytecode/java_string_library_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,11 @@ void java_string_library_preprocesst::code_assign_java_string_to_string_expr(
// Although we should not reach this code if rhs is null, the association
// `pointer -> length` is added to the solver anyway, so we have to make sure
// the length is set to something reasonable.
const auto rhs_length = if_exprt(
auto rhs_length = if_exprt(
equal_exprt(rhs, null_pointer_exprt(to_pointer_type(rhs.type()))),
from_integer(0, lhs.length().type()),
get_length(deref, symbol_table));
rhs_length.set(ID_mode, ID_java);

// Assignments
code.add(code_assignt(lhs.length(), rhs_length), loc);
Expand Down