Skip to content

Commit

Permalink
fix abi head validation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberthirst committed Apr 9, 2024
1 parent 8fcbde2 commit 2ffb67b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vyper/codegen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,9 @@ def _mul(x, y):


# Resolve pointer locations for ABI-encoded data
def _getelemptr_abi_helper(parent, member_t, ofst, clamp=True):
def _getelemptr_abi_helper(parent, member_t, ofst, clamp_=True):
member_abi_t = member_t.abi_type
parent_abi_t = parent.typ.abi_type

# ABI encoding has length word and then pretends length is not there
# e.g. [[1,2]] is encoded as 0x01 <len> 0x20 <inner array ofst> <encode(inner array)>
Expand All @@ -457,11 +458,17 @@ def _getelemptr_abi_helper(parent, member_t, ofst, clamp=True):
ofst_ir = add_ofst(parent, ofst)

if member_abi_t.is_dynamic():
abi_ofst = unwrap_location(ofst_ir)
# double dereference, according to ABI spec
# TODO optimize special case: first dynamic item
# offset is statically known.
ofst_ir = add_ofst(parent, unwrap_location(ofst_ir))

if parent.location == MEMORY: # TODO: replace with utility function
bound = parent_abi_t.size_bound()
abi_ofst = clamp("le", abi_ofst, bound)
ofst_ir = add_ofst(parent, abi_ofst)

return IRnode.from_list(
ofst_ir,
typ=member_t,
Expand Down

0 comments on commit 2ffb67b

Please sign in to comment.