Skip to content

Commit

Permalink
fix: add check to prevent dynamic-length struct as a function input
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Oct 10, 2020
1 parent 7c92f3a commit 4e9ede9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vyper/context/types/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from vyper.context.namespace import get_namespace
from vyper.context.types.bases import BaseTypeDefinition, DataLocation
from vyper.context.types.indexable.sequence import TupleDefinition
from vyper.context.types.meta.struct import StructDefinition
from vyper.context.types.utils import (
StringEnum,
check_constant,
Expand Down Expand Up @@ -290,6 +291,11 @@ def from_FunctionDef(
type_definition = get_type_from_annotation(
arg.annotation, location=DataLocation.CALLDATA, is_immutable=True
)
if isinstance(type_definition, StructDefinition) and type_definition.is_dynamic_size:
raise ArgumentException(
"Struct with dynamically sized data cannot be used as a function input", arg
)

if value is not None:
if not check_constant(value):
raise StateAccessViolation(
Expand Down

0 comments on commit 4e9ede9

Please sign in to comment.