mirror of
https://github.com/golang/go
synced 2024-09-28 17:24:28 -06:00
database/sql: fix memory leaks in Stmt.removeClosedStmtLocked
Zero out elements before shrinking the slice to avoid memory leaks. Fixes #66410
This commit is contained in:
parent
f94d82b2c0
commit
b15586e801
@ -2684,6 +2684,8 @@ func (s *Stmt) removeClosedStmtLocked() {
|
||||
for i := 0; i < len(s.css); i++ {
|
||||
if s.css[i].dc.dbmuClosed {
|
||||
s.css[i] = s.css[len(s.css)-1]
|
||||
// Zero out the last element (for GC) before shrinking the slice.
|
||||
s.css[len(s.css)-1] = connStmt{}
|
||||
s.css = s.css[:len(s.css)-1]
|
||||
i--
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user