File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,11 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
236236 return formatFatalError (" JSONError" , " Only \" Solidity\" is supported as a language." );
237237
238238 Json::Value const & sources = _input[" sources" ];
239- if (!sources)
239+
240+ if (!sources.isObject () && !sources.isNull ())
241+ return formatFatalError (" JSONError" , " Sources input is not a JSON object." );
242+
243+ if (sources.empty ())
240244 return formatFatalError (" JSONError" , " No input sources specified." );
241245
242246 Json::Value errors = Json::arrayValue;
Original file line number Diff line number Diff line change @@ -154,6 +154,42 @@ BOOST_AUTO_TEST_CASE(no_sources)
154154 BOOST_CHECK (containsError (result, " JSONError" , " No input sources specified." ));
155155}
156156
157+ BOOST_AUTO_TEST_CASE (no_sources_empty_object)
158+ {
159+ char const * input = R"(
160+ {
161+ "language": "Solidity",
162+ "sources": {}
163+ }
164+ )" ;
165+ Json::Value result = compile (input);
166+ BOOST_CHECK (containsError (result, " JSONError" , " No input sources specified." ));
167+ }
168+
169+ BOOST_AUTO_TEST_CASE (no_sources_empty_array)
170+ {
171+ char const * input = R"(
172+ {
173+ "language": "Solidity",
174+ "sources": []
175+ }
176+ )" ;
177+ Json::Value result = compile (input);
178+ BOOST_CHECK (containsError (result, " JSONError" , " Sources input is not a JSON object." ));
179+ }
180+
181+ BOOST_AUTO_TEST_CASE (sources_is_array)
182+ {
183+ char const * input = R"(
184+ {
185+ "language": "Solidity",
186+ "sources": ["aa", "bb"]
187+ }
188+ )" ;
189+ Json::Value result = compile (input);
190+ BOOST_CHECK (containsError (result, " JSONError" , " Sources input is not a JSON object." ));
191+ }
192+
157193BOOST_AUTO_TEST_CASE (smoke_test)
158194{
159195 char const * input = R"(
You can’t perform that action at this time.
0 commit comments