mirror of
https://github.com/github/codeql.git
synced 2026-06-14 17:31:09 +02:00
27 lines
476 B
Go
27 lines
476 B
Go
package main
|
|
|
|
func test() {
|
|
var xs []int
|
|
for _ = range xs {
|
|
defer test() // $ Alert[go/examples/deferinloop] // not ok
|
|
}
|
|
|
|
for _ = range xs {
|
|
if true {
|
|
defer test() // $ Alert[go/examples/deferinloop] // not ok
|
|
}
|
|
}
|
|
|
|
for i := 0; i < 10; i++ {
|
|
defer test() // $ Alert[go/examples/deferinloop]
|
|
}
|
|
|
|
for true {
|
|
defer test() // $ Alert[go/examples/deferinloop] // not ok
|
|
}
|
|
|
|
for false {
|
|
defer test() // $ Alert[go/examples/deferinloop] // fine but caught
|
|
}
|
|
}
|