Commit fcd05d6c authored by Loïck Bonniot's avatar Loïck Bonniot

[gui][c] Fix unmarshal when corrupted dfss json

Fix #10
parent 87d3948f
Pipeline #1181 failed with stage
......@@ -2,6 +2,7 @@ package common
import (
"encoding/json"
"errors"
"dfss/dfssp/contract"
)
......@@ -15,5 +16,9 @@ func UnmarshalDFSSFile(data []byte) (*contract.JSON, error) {
return nil, err
}
if c.File == nil {
return nil, errors.New("empty file description")
}
return c, nil
}
......@@ -2,9 +2,9 @@
package showcontract
import (
"encoding/json"
"io/ioutil"
"dfss/dfssc/common"
"dfss/dfssp/contract"
"github.com/visualfc/goqt/ui"
)
......@@ -49,8 +49,7 @@ func Load(filename string) *contract.JSON {
return nil
}
contract := new(contract.JSON)
err = json.Unmarshal(data, contract)
contract, err := common.UnmarshalDFSSFile(data)
if err != nil {
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment