Skip to content

Commit

Permalink
allow backwards jumps iff offset is shared between items
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Mar 25, 2022
1 parent 15ce979 commit e042a12
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/com/esaulpaugh/headlong/abi/TupleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,16 @@ static void decodeObjects(boolean dynamic, ByteBuffer bb, byte[] unitBuffer, Int
if (jump != pos) {
/* LENIENT MODE; see https://github.com/ethereum/solidity/commit/3d1ca07e9b4b42355aa9be5db5c00048607986d1 */
if (jump < pos) {
throw new IllegalArgumentException("illegal backwards jump: (" + start + "+" + offset + "=" + jump + ")<" + pos);
boolean shared = false;
for (int j = 0; j < i; j++) {
if (offsets[j] == offset) {
shared = true;
break;
}
}
if(!shared) {
throw new IllegalArgumentException("illegal backwards jump: (" + start + "+" + offset + "=" + jump + ")<" + pos);
}
}
bb.position(jump); // leniently jump to specified offset
}
Expand Down

0 comments on commit e042a12

Please sign in to comment.