github-vet / github-vet/rangeloop-pointer-findings
jackc/tpr-deb: backend/vendor/github.com/jackc/pgx/query.go; 70 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [jackc/tpr-deb](https://www.github.com/jackc/tpr-deb) at [backend/vendor/github.com/jackc/pgx/query.go](https://github.com/jackc/tpr-deb/blob/511ee902824d07c3ab7dea67286d8866249a3083/backend/vendor/github.com/jackc/pgx/query.go#L240-L309)
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.
>
[Click here to see the code in its original context.](https://github.com/jackc/tpr-deb/blob/511ee902824d07c3ab7dea67286d8866249a3083/backend/vendor/github.com/jackc/pgx/query.go#L240-L309)
Click here to show the 70 line(s) of Go which triggered the analyzer.
```go
for i, d := range dest {
vr, _ := rows.nextColumn()
// Check for []byte first as we allow sidestepping the decoding process and retrieving the raw bytes
if b, ok := d.(*[]byte); ok {
// If it actually is a bytea then pass it through decodeBytea (so it can be decoded if it is in text format)
// Otherwise read the bytes directly regardless of what the actual type is.
if vr.Type().DataType == ByteaOid {
*b = decodeBytea(vr)
} else {
if vr.Len() != -1 {
*b = vr.ReadBytes(vr.Len())
} else {
*b = nil
}
}
} else if s, ok := d.(Scanner); ok {
err = s.Scan(vr)
if err != nil {
rows.Fatal(scanArgError{col: i, err: err})
}
} else if s, ok := d.(sql.Scanner); ok {
var val interface{}
if 0 <= vr.Len() {
switch vr.Type().DataType {
case BoolOid:
val = decodeBool(vr)
case Int8Oid:
val = int64(decodeInt8(vr))
case Int2Oid:
val = int64(decodeInt2(vr))
case Int4Oid:
val = int64(decodeInt4(vr))
case TextOid, VarcharOid:
val = decodeText(vr)
case OidOid:
val = int64(decodeOid(vr))
case Float4Oid:
val = float64(decodeFloat4(vr))
case Float8Oid:
val = decodeFloat8(vr)
case DateOid:
val = decodeDate(vr)
case TimestampOid:
val = decodeTimestamp(vr)
case TimestampTzOid:
val = decodeTimestampTz(vr)
default:
val = vr.ReadBytes(vr.Len())
}
}
err = s.Scan(val)
if err != nil {
rows.Fatal(scanArgError{col: i, err: err})
}
} else if vr.Type().DataType == JsonOid || vr.Type().DataType == JsonbOid {
decodeJson(vr, &d)
} else {
if err := Decode(vr, d); err != nil {
rows.Fatal(scanArgError{col: i, err: err})
}
}
if vr.Err() != nil {
rows.Fatal(scanArgError{col: i, err: vr.Err()})
}
if rows.Err() != nil {
return rows.Err()
}
}
```
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.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {decodeJson 2} was not found in the callgraph; reference was passed directly to third-party code
```
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: 511ee902824d07c3ab7dea67286d8866249a3083
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.