mirror of
https://github.com/github/codeql.git
synced 2026-02-01 07:42:57 +01:00
16 lines
479 B
Plaintext
16 lines
479 B
Plaintext
/**
|
|
* @name Defer in loop
|
|
* @description A deferred statement in a loop will not execute until the end of the function.
|
|
* This can lead to unintentionally holding resources open like file handles or database transactions.
|
|
* @id go/examples/deferinloop
|
|
* @kind problem
|
|
* @tags defer
|
|
* nesting
|
|
*/
|
|
|
|
import go
|
|
|
|
from LoopStmt loop, DeferStmt defer
|
|
where loop.getBody().getAChildStmt+() = defer
|
|
select defer, "This defer statement is in a $@.", loop, "loop"
|