github-vet / github-vet/rangeloop-pointer-findings

lvleiice/Better-PITR: pitr/merge.go; 51 LoC

Open
#9,307 0 comments 0 reactions 0 assignees View on GitHub
fresh medium
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [lvleiice/Better-PITR](https://www.github.com/lvleiice/Better-PITR) at [pitr/merge.go](https://github.com/lvleiice/Better-PITR/blob/198eaf86ed09118a4c3bb8045b26d8eed3cb7e6b/pitr/merge.go#L414-L464)

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.

> reference to event is reassigned at line 418

[Click here to see the code in its original context.](https://github.com/lvleiice/Better-PITR/blob/198eaf86ed09118a4c3bb8045b26d8eed3cb7e6b/pitr/merge.go#L414-L464)

Click here to show the 51 line(s) of Go which triggered the analyzer.

```go
for _, event := range dml.Events {
schema := event.GetSchemaName()
table := event.GetTableName()

e := &event
tp := e.GetTp()
row := e.GetRow()

var r *Event

tableInfo, err := ddlHandle.GetTableInfo(schema, table)
if err != nil {
return nil, err
}

switch tp {
case pb.EventType_Insert, pb.EventType_Delete:
key, cols, err := getInsertAndDeleteRowKey(row, tableInfo)
if err != nil {
return nil, err
}

r = &Event{
schema: schema,
table: table,
eventType: tp,
oldKey: key,
cols: cols,
}

case pb.EventType_Update:
key, cKey, cols, err := getUpdateRowKey(row, tableInfo)
if err != nil {
return nil, err
}

r = &Event{
schema: schema,
table: table,
eventType: tp,
oldKey: key,
newKey: cKey,
cols: cols,
}

default:
panic("unreachable")
}

tm.HandleEvent(r)
}

```

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: 198eaf86ed09118a4c3bb8045b26d8eed3cb7e6b

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.