Skip to content

Commit

Permalink
fix nil pointer, see 1198
Browse files Browse the repository at this point in the history
  • Loading branch information
jordipainan committed Nov 23, 2023
1 parent 22552f1 commit ae80c39
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,29 @@ func (a *API) accountHandler(_ *apirest.APIdata, ctx *httprouter.HTTPContext) er
// @Router /accounts [post]
func (a *API) accountSetHandler(msg *apirest.APIdata, ctx *httprouter.HTTPContext) error {
req := &AccountSet{}
if msg == nil || msg.Data == nil {
return ErrCantParseDataAsJSON
}

if err := json.Unmarshal(msg.Data, req); err != nil {
return err
}

// check if the transaction is of the correct type and extract metadata URI
metadataURI, err := func() (string, error) {
stx := &models.SignedTx{}
if req.TxPayload == nil {
return "", ErrUnmarshalingServerProto
}
if err := proto.Unmarshal(req.TxPayload, stx); err != nil {
return "", err
}
tx := &models.Tx{}
if err := proto.Unmarshal(stx.GetTx(), tx); err != nil {
gotTx := stx.GetTx()
if gotTx == nil {
return "", ErrUnmarshalingServerProto
}
if err := proto.Unmarshal(gotTx, tx); err != nil {
return "", err
}
if np := tx.GetSetAccount(); np != nil {
Expand Down

0 comments on commit ae80c39

Please sign in to comment.