[ctr/lua] bug fix panic when contract call with invalid argument
@@ -301,12 +301,14 @@ func Call(contractState *state.ContractState, code, contractAddress []byte,
err = fmt.Errorf("cannot find contract %s", string(contractAddress))
ctrLog.Warn().AnErr("err", err)
}
- var ce *Executor
- if err == nil {
+ if err != nil {
+ return "", nil
+ }
if ctrLog.IsDebugEnabled() {
ctrLog.Debug().Str("abi", string(code)).Msgf("contract %s", types.EncodeAddress(contractAddress))
}
- ce = newExecutor(contract, bcCtx)
+
+ ce := newExecutor(contract, bcCtx)
defer ce.close(true)
ce.call(&ci, nil)
err = ce.err
@@ -315,7 +317,6 @@ func Call(contractState *state.ContractState, code, contractAddress []byte,
} else {
ctrLog.Warn().AnErr("err", err).Msgf("contract call is failed")
}
- }
return ce.jsonRet, err
}
