fix: potential resource leak
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 4m17s

This commit is contained in:
2025-12-17 21:38:00 +07:00
parent 2725975d82
commit 6451304ed7
7 changed files with 63 additions and 237 deletions

View File

@ -298,13 +298,22 @@ func forwardRequest(cw *CustomWriter, initialRequest *RequestHeaderFactory, sshS
channel, reqs, err := sshSession.Lifecycle.GetConnection().OpenChannel("forwarded-tcpip", payload)
if err != nil {
log.Printf("Failed to open forwarded-tcpip channel: %v", err)
if closer, ok := cw.writer.(io.Closer); ok {
if closeErr := closer.Close(); closeErr != nil {
log.Printf("Failed to close connection: %v", closeErr)
}
}
return
}
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("Panic in request handler goroutine: %v", r)
}
}()
for req := range reqs {
err := req.Reply(false, nil)
if err != nil {
if err := req.Reply(false, nil); err != nil {
log.Printf("Failed to reply to request: %v", err)
return
}