Skip to content

Commit 836be74

Browse files
Merge pull request #1103 from romainbrenguier/bugfix/declare-pointer-before-use
Declare malloc-site symbols before they are used
2 parents 9419454 + 8082795 commit 836be74

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
test.class
3+
--refine-strings --show-goto-functions
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
char \([*]malloc_site.[0-9]*\)\[INFINITY\(\)\];\n\s*//.*\n\s*malloc_site.[0-9]*\s*=\s*MALLOC\(char \[INFINITY\(\)\], 2ull? \* INFINITY\(\)\);\n\s*//.*\n\s*cprover_string_array.[0-9]*\s*=\s*malloc_site.\d*;
9+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class test
2+
{
3+
public static void check()
4+
{
5+
String s = new String("foo");
6+
String t = new String("bar");
7+
String u = s.concat(t);
8+
}
9+
}

src/java_bytecode/java_object_factory.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,13 @@ exprt allocate_dynamic_object_with_decl(
224224
{
225225
std::vector<const symbolt *> symbols_created;
226226

227+
code_blockt tmp_block;
227228
exprt result=allocate_dynamic_object(
228229
target_expr,
229230
allocate_type,
230231
symbol_table,
231232
loc,
232-
output_code,
233+
tmp_block,
233234
symbols_created,
234235
cast_needed);
235236

@@ -242,6 +243,9 @@ exprt allocate_dynamic_object_with_decl(
242243
output_code.add(decl);
243244
}
244245

246+
for(const exprt &code : tmp_block.operands())
247+
output_code.add(to_code(code));
248+
245249
return result;
246250
}
247251

0 commit comments

Comments
 (0)