github-vet / github-vet/rangeloop-pointer-findings
zwcui/baseMircoApi: taskservice/task/payOrderTask.go; 48 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [zwcui/baseMircoApi](https://www.github.com/zwcui/baseMircoApi) at [taskservice/task/payOrderTask.go](https://github.com/zwcui/baseMircoApi/blob/727407c592608a0b30883b9b89b93ca259952c14/taskservice/task/payOrderTask.go#L44-L91)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> function call at line 70 passes reference to account to third-party code
[Click here to see the code in its original context.](https://github.com/zwcui/baseMircoApi/blob/727407c592608a0b30883b9b89b93ca259952c14/taskservice/task/payOrderTask.go#L44-L91)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for _, account := range accountList {
session := base.DBEngine.NewSession()
defer session.Close()
err := session.Begin()
if err != nil {
util.Logger.Info("settle" + strconv.Itoa(settlementType) + " session.Begin() err:" + err.Error())
session.Close()
continue
}
//每日结算
var cashOut models.CashOut
cashOut.TransferType = 2
cashOut.SettlementType = account.SettlementType
cashOut.AuthorId = account.AuthorId
cashOut.Amount = account.UnsettledAmount
cashOut.Status = 0
_, err = session.Table("cash_out").InsertOne(&cashOut)
response, err := models.WeChatTransfers(ip, &cashOut, session)
if err != nil {
errCodeDes := strings.Split(err.Error(), ":")[0]
errCode := strings.Split(err.Error(), ":")[1]
util.Logger.Info("settle" + strconv.Itoa(settlementType) + " 微信转账失败 err = " + errCodeDes)
cashOut.ErrorCode = errCode
cashOut.ErrorCodeDes = errCodeDes
models.TransfersFail(&cashOut, &account, session)
} else {
cashOut.PaymentNo = response.PaymentNo
cashOut.TransferTime = response.PaymentTime
cashOut.ErrorCode = response.ErrCode
cashOut.ErrorCodeDes = response.ErrCodeDes
models.TransfersSucceed(&cashOut, &account, session)
}
account.UnsettledAmount = 0
_, err = session.Table("author_account").Where("author_id=?", account.AuthorId).Cols("unsettled_amount").Update(&account)
if err != nil {
session.Rollback()
util.Logger.Info("settle" + strconv.Itoa(settlementType) + " err:" + err.Error())
}
err = session.Commit()
if err != nil {
session.Rollback()
util.Logger.Info("settle" + strconv.Itoa(settlementType) + " session.Commit() err:" + err.Error())
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
The following graphviz dot graph describes paths through the callgraph that could lead to a function which passes a pointer to third-party code:
digraph G {
"(TransfersFail, 3)" -> {"(UpdateAccount, 8)";}
"(UpdateAccount, 8)" -> {}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 727407c592608a0b30883b9b89b93ca259952c14
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.