Memory Memoryaliasing

Go's `for ... range` statements create an iteration variable for each iteration of the loop. By taking the address of this iteration variable, the value of the address will be re-used and always point to the same location in memory. This can have unexpected behavior if the address is stored or re-used. This can be fixed by: - Not referencing the address of t

IndexedPublic repositoryMediumHigh confidenceVerifiedApache-2.0go
greprules fetch gitlab-sast-go-memory-rule-memoryaliasing --engine opengrep

Description

Go's `for ... range` statements create an iteration variable for each iteration of the loop. By taking the address of this iteration variable, the value of the address will be re-used and always point to the same location in memory. This can have unexpected behavior if the address is stored or re-used. This can be fixed by: - Not referencing the address of t

Detection target

Not provided

Recommended fix

Not provided

False-positive notes

Not provided

Community feedback

Sign in to report false positives, mark this rule useful, or suggest metadata improvements.