aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface/StandardCompiler.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-01 00:40:29 +0800
committerGitHub <noreply@github.com>2018-03-01 00:40:29 +0800
commit7938339572d8f2f1ab4f9ef335076250f1f09b6c (patch)
treea899bf48fe0ab33fa81b521e44aa095bf411b568 /libsolidity/interface/StandardCompiler.cpp
parentfb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9 (diff)
parent7897301b7179603a1bc74d7be9eff6ccc67398db (diff)
downloaddexon-solidity-7938339572d8f2f1ab4f9ef335076250f1f09b6c.tar.gz
dexon-solidity-7938339572d8f2f1ab4f9ef335076250f1f09b6c.tar.zst
dexon-solidity-7938339572d8f2f1ab4f9ef335076250f1f09b6c.zip
Merge pull request #3617 from ethereum/jsonio-libraries
Add more comprehensive tests and checks for libraries in JSONIO
Diffstat (limited to 'libsolidity/interface/StandardCompiler.cpp')
-rw-r--r--libsolidity/interface/StandardCompiler.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp
index fb973d51..8c64c164 100644
--- a/libsolidity/interface/StandardCompiler.cpp
+++ b/libsolidity/interface/StandardCompiler.cpp
@@ -327,13 +327,29 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
m_compilerStack.setOptimiserSettings(optimize, optimizeRuns);
map<string, h160> libraries;
- Json::Value jsonLibraries = settings.get("libraries", Json::Value());
+ Json::Value jsonLibraries = settings.get("libraries", Json::Value(Json::objectValue));
+ if (!jsonLibraries.isObject())
+ return formatFatalError("JSONError", "\"libraries\" is not a JSON object.");
for (auto const& sourceName: jsonLibraries.getMemberNames())
{
auto const& jsonSourceName = jsonLibraries[sourceName];
+ if (!jsonSourceName.isObject())
+ return formatFatalError("JSONError", "library entry is not a JSON object.");
for (auto const& library: jsonSourceName.getMemberNames())
- // @TODO use libraries only for the given source
- libraries[library] = h160(jsonSourceName[library].asString());
+ {
+ try
+ {
+ // @TODO use libraries only for the given source
+ libraries[library] = h160(jsonSourceName[library].asString());
+ }
+ catch (dev::BadHexCharacter)
+ {
+ return formatFatalError(
+ "JSONError",
+ "Invalid library address (\"" + jsonSourceName[library].asString() + "\") supplied."
+ );
+ }
+ }
}
m_compilerStack.setLibraries(libraries);