Skip to content

Commit

Permalink
signer/core: handle JSON unmarshal error (ethereum#19123)
Browse files Browse the repository at this point in the history
  • Loading branch information
htkao authored and karalabe committed Feb 19, 2019
1 parent 4a090a1 commit c283d9b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions signer/core/abihelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func NewAbiDBFromFile(path string) (*AbiDb, error) {
if err != nil {
return nil, err
}
json.Unmarshal(raw, &db.db)
if err := json.Unmarshal(raw, &db.db); err != nil {
return nil, err
}
return db, nil
}

Expand All @@ -192,14 +194,18 @@ func NewAbiDBFromFiles(standard, custom string) (*AbiDb, error) {
if err != nil {
return nil, err
}
json.Unmarshal(raw, &db.db)
if err := json.Unmarshal(raw, &db.db); err != nil {
return nil, err
}
// Custom file may not exist. Will be created during save, if needed
if _, err := os.Stat(custom); err == nil {
raw, err = ioutil.ReadFile(custom)
if err != nil {
return nil, err
}
json.Unmarshal(raw, &db.customdb)
if err := json.Unmarshal(raw, &db.customdb); err != nil {
return nil, err
}
}

return db, nil
Expand Down

0 comments on commit c283d9b

Please sign in to comment.