diff options
author | chriseth <chris@ethereum.org> | 2016-10-24 23:00:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-24 23:00:44 +0800 |
commit | 067109e1ae5199f285d7cae211930cf9449f65f4 (patch) | |
tree | 171fbfef357688e567e5b3a48ea0b4363a1916ba /libsolidity/codegen | |
parent | 22f2c6df6316b1281753e1c626ad5523e8917246 (diff) | |
parent | f25aa0c68bd8d4c2acf9425c9aba15fc56b16ccc (diff) | |
download | dexon-solidity-067109e1ae5199f285d7cae211930cf9449f65f4.tar.gz dexon-solidity-067109e1ae5199f285d7cae211930cf9449f65f4.tar.zst dexon-solidity-067109e1ae5199f285d7cae211930cf9449f65f4.zip |
Merge pull request #1266 from ethereum/fixcrash
Fix a crash related to invalid number literals.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 3 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 18 |
2 files changed, 16 insertions, 5 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index ec496df8..e064c1a6 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -368,8 +368,11 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp m_context << (u256(1) << (256 - targetBytesType.numBytes() * 8)) << Instruction::MUL; } else if (targetTypeCategory == Type::Category::Enum) + { + solAssert(_typeOnStack.mobileType(), ""); // just clean convertType(_typeOnStack, *_typeOnStack.mobileType(), true); + } else if (targetTypeCategory == Type::Category::FixedPoint) { solAssert( diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index da3e56cc..6d54b48b 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -56,8 +56,10 @@ void ExpressionCompiler::appendStateVariableInitialization(VariableDeclaration c if (_varDecl.annotation().type->dataStoredIn(DataLocation::Storage)) { // reference type, only convert value to mobile type and do final conversion in storeValue. - utils().convertType(*type, *type->mobileType()); - type = type->mobileType(); + auto mt = type->mobileType(); + solAssert(mt, ""); + utils().convertType(*type, *mt); + type = mt; } else { @@ -1437,11 +1439,17 @@ void ExpressionCompiler::appendExternalFunctionCall( // Evaluate arguments. TypePointers argumentTypes; TypePointers parameterTypes = _functionType.parameterTypes(); - bool manualFunctionId = + bool manualFunctionId = false; + if ( (funKind == FunctionKind::Bare || funKind == FunctionKind::BareCallCode || funKind == FunctionKind::BareDelegateCall) && - !_arguments.empty() && - _arguments.front()->annotation().type->mobileType()->calldataEncodedSize(false) == + !_arguments.empty() + ) + { + solAssert(_arguments.front()->annotation().type->mobileType(), ""); + manualFunctionId = + _arguments.front()->annotation().type->mobileType()->calldataEncodedSize(false) == CompilerUtils::dataStartOffset; + } if (manualFunctionId) { // If we have a Bare* and the first type has exactly 4 bytes, use it as |