diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-07 19:13:52 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-08-07 20:18:38 +0800 |
commit | eb7b3862ac5089615710d07c9a56b8edc0472394 (patch) | |
tree | 4bb0af26fbbb098267140b11838b72eb9e9037ae | |
parent | 8b2d630275fb29d2915af76f608be4d4e422907f (diff) | |
download | dexon-solidity-eb7b3862ac5089615710d07c9a56b8edc0472394.tar.gz dexon-solidity-eb7b3862ac5089615710d07c9a56b8edc0472394.tar.zst dexon-solidity-eb7b3862ac5089615710d07c9a56b8edc0472394.zip |
Properly handle invalid references used together with _slot and _offset.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/ReferencesResolver.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol | 9 |
3 files changed, 12 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md index e00f74b3..037451ed 100644 --- a/Changelog.md +++ b/Changelog.md @@ -83,6 +83,7 @@ Bugfixes: * Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions. * References Resolver: Do not crash on using ``_slot`` and ``_offset`` suffixes on their own. * References Resolver: Enforce ``storage`` as data location for mappings. + * References Resolver: Properly handle invalid references used together with ``_slot`` and ``_offset``. * References Resolver: Report error instead of assertion fail when FunctionType has an undeclared type as parameter. * Type Checker: Disallow assignments to mappings within tuple assignments as well. * Type Checker: Allow assignments to local variables of mapping types. diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 5458c1b0..b888ecd6 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -262,6 +262,8 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) return size_t(-1); } declarations = m_resolver.nameFromCurrentScope(realName); + if (!dynamic_cast<VariableDeclaration const*>(declarations.front())) + return size_t(-1); } if (declarations.size() != 1) return size_t(-1); diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol new file mode 100644 index 00000000..6838e7a4 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_function.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + let x := f_slot + } + } +} +// ---- +// DeclarationError: (84-90): Identifier not found. |