Skip to content

Commit

Permalink
common/compiler: json unmarshalling error checks (ethereum#25449)
Browse files Browse the repository at this point in the history
complier/solidity:add json.Unmarshal err check
  • Loading branch information
henry-0 authored and cp-wjhan committed Oct 10, 2023
1 parent ffc23b0 commit cd679b3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions common/compiler/solidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
contracts := make(map[string]*Contract)
for name, info := range output.Contracts {
// Parse the individual compilation results.
var abi interface{}
var abi, userdoc, devdoc interface{}
if err := json.Unmarshal([]byte(info.Abi), &abi); err != nil {
return nil, fmt.Errorf("solc: error reading abi definition (%v)", err)
}
var userdoc, devdoc interface{}
json.Unmarshal([]byte(info.Userdoc), &userdoc)
json.Unmarshal([]byte(info.Devdoc), &devdoc)
if err := json.Unmarshal([]byte(info.Userdoc), &userdoc); err != nil {
return nil, fmt.Errorf("solc: error reading userdoc definition (%v)", err)
}
if err := json.Unmarshal([]byte(info.Devdoc), &devdoc); err != nil {
return nil, fmt.Errorf("solc: error reading devdoc definition (%v)", err)
}

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

0 comments on commit cd679b3

Please sign in to comment.