Skip to content

Commit 49aa8a6

Browse files
authored
common/compiler: json unmarshalling error checks (ethereum#25449)
complier/solidity:add json.Unmarshal err check
1 parent fea569f commit 49aa8a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/compiler/solidity.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
6666
contracts := make(map[string]*Contract)
6767
for name, info := range output.Contracts {
6868
// Parse the individual compilation results.
69-
var abi interface{}
69+
var abi, userdoc, devdoc interface{}
7070
if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil {
7171
return nil, fmt.Errorf("solc: error reading abi definition (%v)", err)
7272
}
73-
var userdoc, devdoc interface{}
74-
json.Unmarshal([]byte(info.Userdoc), &userdoc)
75-
json.Unmarshal([]byte(info.Devdoc), &devdoc)
73+
if err := json.Unmarshal([]byte(info.Userdoc), &userdoc); err != nil {
74+
return nil, fmt.Errorf("solc: error reading userdoc definition (%v)", err)
75+
}
76+
if err := json.Unmarshal([]byte(info.Devdoc), &devdoc); err != nil {
77+
return nil, fmt.Errorf("solc: error reading devdoc definition (%v)", err)
78+
}
7679

7780
contracts[name] = &Contract{
7881
Code: "0x" + info.Bin,

0 commit comments

Comments
 (0)