Skip to content

Commit a14185a

Browse files
committed
Merge pull request #392 from chriseth/fixsegfault
Fixsegfault
2 parents c6c3c78 + 4a83716 commit a14185a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libsolidity/analysis/TypeChecker.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ void TypeChecker::visitManually(
504504
return;
505505
}
506506
if (parameters->size() != arguments.size())
507+
{
507508
typeError(
508509
_modifier.location(),
509510
"Wrong argument count for modifier invocation: " +
@@ -512,6 +513,8 @@ void TypeChecker::visitManually(
512513
toString(parameters->size()) +
513514
"."
514515
);
516+
return;
517+
}
515518
for (size_t i = 0; i < _modifier.arguments().size(); ++i)
516519
if (!type(*arguments[i])->isImplicitlyConvertibleTo(*type(*(*parameters)[i])))
517520
typeError(

test/libsolidity/SolidityNameAndTypeResolution.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,6 +3136,21 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types)
31363136
BOOST_CHECK(success(text));
31373137
}
31383138

3139+
BOOST_AUTO_TEST_CASE(constructor_call_invalid_arg_count)
3140+
{
3141+
// This caused a segfault in an earlier version
3142+
char const* text = R"(
3143+
contract C {
3144+
function C(){}
3145+
}
3146+
contract D is C {
3147+
function D() C(5){}
3148+
}
3149+
)";
3150+
3151+
BOOST_CHECK(expectError(text) == Error::Type::TypeError);
3152+
}
3153+
31393154
BOOST_AUTO_TEST_CASE(index_access_for_bytes)
31403155
{
31413156
char const* text = R"(

0 commit comments

Comments
 (0)