mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
util/winutil/s4u: fix token handle leak
Fixes #14156 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
parent
810da91a9e
commit
48343ee673
@ -17,6 +17,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -128,9 +129,10 @@ func Login(logf logger.Logf, srcName string, u *user.User, capLevel CapabilityLe
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
tokenCloseOnce := sync.OnceFunc(func() { token.Close() })
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
token.Close()
|
tokenCloseOnce()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -162,6 +164,7 @@ func Login(logf logger.Logf, srcName string, u *user.User, capLevel CapabilityLe
|
|||||||
sessToken.Close()
|
sessToken.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
tokenCloseOnce()
|
||||||
}
|
}
|
||||||
|
|
||||||
userProfile, err := winutil.LoadUserProfile(sessToken, u)
|
userProfile, err := winutil.LoadUserProfile(sessToken, u)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user