Skip to content

Commit

Permalink
add comment for decode clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberthirst committed Apr 23, 2024
1 parent da0a59a commit 333c7bf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vyper/codegen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ def _getelemptr_abi_helper(parent, member_t, ofst, clamp_=True):
bound -= MEMORY.word_scale * DYNAMIC_ARRAY_OVERHEAD
ofst_ir = [
"seq",
# the bound check is strickter than it has to be but it satisfies the ABI spec
# it assumes that the length of the type pointed to by the head is maximal for
# the given type (the parent bufffer is big enough to contain the maximal subtyp).
# the actual runtime length might be smaller, so if we checked the runtime value
# we could allow invalid head values as long as:
# - invalid_head + length_word + length*item_size <= bound
check_buffer_overflow_ir(abi_ofst, member_abi_t.size_bound(), bound),
add_ofst(parent, abi_ofst),
]
Expand Down

0 comments on commit 333c7bf

Please sign in to comment.