Language: Python
Label: safe
CWE: CWE-789 \u2014 Memory Allocation with Excessive Size Value
The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.

Code:
def set_code_offsets(vyper_module: vy_ast.Module) -> Dict:
    ret = {}
    offset = 0

    for node in vyper_module.get_children(vy_ast.VariableDecl, filters={"is_immutable": True}):
        varinfo = node.target._metadata["varinfo"]
        type_ = varinfo.typ
        varinfo.set_position(CodeOffset(offset))

        len_ = ceil32(type_.size_in_bytes)

        # this could have better typing but leave it untyped until
        # we understand the use case better
        ret[node.target.id] = {"type": str(type_), "offset": offset, "length": len_}

        offset += len_

    return ret