Skip to content

Commit a63212e

Browse files
author
Matthias Güdemann
committed
Add regression test for stack variables with typecasts
This regression test mimicks the bytecode that exhibited the error in Tika.
1 parent 6f63050 commit a63212e

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.class stack_typecast
2+
.super java/lang/Object
3+
4+
.field public position I
5+
.field public buffer [B
6+
7+
.method public <init>()V
8+
aload_0
9+
invokevirtual java/lang/Object/<init>()V
10+
return
11+
.end method
12+
13+
.method public f()I
14+
.limit stack 6
15+
.limit locals 1
16+
.var 0 is this stack_typecast from begin to end
17+
.line 0
18+
begin:
19+
20+
sipush 255
21+
22+
aload_0
23+
getfield stack_typecast/buffer [B
24+
25+
aload_0
26+
dup
27+
getfield stack_typecast/position I
28+
dup_x1
29+
iconst_1
30+
iadd
31+
putfield stack_typecast/position I
32+
baload
33+
iand
34+
end:
35+
ireturn
36+
37+
.end method
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
stack_typecast.class
3+
--cover location --function stack_typecast.f
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
covered \(100.0%\)
7+
--
8+
--
9+
This tests that there is no invariant violation when modifying the values on the
10+
stack. in this case the `position` variable is used as index in an array via the
11+
Java equivalent of
12+
13+
buffer[position++];
14+
15+
The code pushes position, duplicates it and the modifies the stack
16+
entry. Before, the stack entry generation removed typecasts which gave a typing
17+
problem with the `iand` operator

0 commit comments

Comments
 (0)