Skip to content

Commit a8cb01e

Browse files
committed
Prevent panic when wintun dll fails to load
1 parent b76e852 commit a8cb01e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/wintun/wintun_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func closeAdapter(wintun *Adapter) {
3939
// deterministically. If it is set to nil, the GUID is chosen by the system at random,
4040
// and hence a new NLA entry is created for each new adapter.
4141
func CreateAdapter(name string, tunnelType string, requestedGUID *windows.GUID) (wintun *Adapter, err error) {
42+
err = procWintunCloseAdapter.Find()
43+
if err != nil {
44+
return
45+
}
4246
var name16 *uint16
4347
name16, err = windows.UTF16PtrFromString(name)
4448
if err != nil {

0 commit comments

Comments
 (0)