Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libsolidity/interface/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
{
string hash;

if (sourceName.empty())
return formatFatalError("JSONError", "Source name cannot be empty.");

if (!sources[sourceName].isObject())
return formatFatalError("JSONError", "Source input is not a JSON object.");

Expand Down
16 changes: 16 additions & 0 deletions test/libsolidity/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_CHECK(containsAtMostWarnings(result));
}

BOOST_AUTO_TEST_CASE(empty_source_name)
{
char const* input = R"(
{
"language": "Solidity",
"sources": {
"": {
"content": ""
}
}
}
)";
Json::Value result = compile(input);
BOOST_CHECK(containsError(result, "JSONError", "Source name cannot be empty."));
}

BOOST_AUTO_TEST_CASE(basic_compilation)
{
char const* input = R"(
Expand Down