From 8174e79450148c3c736089345692662cd8887175 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 26 Sep 2019 18:41:52 +0200 Subject: winipcfg: ensure we're passing copy to go routines The windows-allocated one gets freed. Reported-by: Odd Stranne Signed-off-by: Jason A. Donenfeld --- tunnel/winipcfg/interface_change_handler.go | 3 ++- tunnel/winipcfg/route_change_handler.go | 3 ++- tunnel/winipcfg/unicast_address_change_handler.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'tunnel') diff --git a/tunnel/winipcfg/interface_change_handler.go b/tunnel/winipcfg/interface_change_handler.go index 50ea6448..57041719 100644 --- a/tunnel/winipcfg/interface_change_handler.go +++ b/tunnel/winipcfg/interface_change_handler.go @@ -64,9 +64,10 @@ func (callback *InterfaceChangeCallback) Unregister() error { } func interfaceChanged(callerContext uintptr, row *MibIPInterfaceRow, notificationType MibNotificationType) uintptr { + rowCopy := *row interfaceChangeMutex.Lock() for cb := range interfaceChangeCallbacks { - go cb.cb(notificationType, row) + go cb.cb(notificationType, &rowCopy) } interfaceChangeMutex.Unlock() return 0 diff --git a/tunnel/winipcfg/route_change_handler.go b/tunnel/winipcfg/route_change_handler.go index 4bdea672..cafa0e97 100644 --- a/tunnel/winipcfg/route_change_handler.go +++ b/tunnel/winipcfg/route_change_handler.go @@ -71,9 +71,10 @@ func (callback *RouteChangeCallback) Unregister() error { } func routeChanged(callerContext uintptr, row *MibIPforwardRow2, notificationType MibNotificationType) uintptr { + rowCopy := *row routeChangeMutex.Lock() for cb := range routeChangeCallbacks { - go cb.cb(notificationType, row) + go cb.cb(notificationType, &rowCopy) } routeChangeMutex.Unlock() return 0 diff --git a/tunnel/winipcfg/unicast_address_change_handler.go b/tunnel/winipcfg/unicast_address_change_handler.go index b126e2ed..fdd2e058 100644 --- a/tunnel/winipcfg/unicast_address_change_handler.go +++ b/tunnel/winipcfg/unicast_address_change_handler.go @@ -64,9 +64,10 @@ func (callback *UnicastAddressChangeCallback) Unregister() error { } func unicastAddressChanged(callerContext uintptr, row *MibUnicastIPAddressRow, notificationType MibNotificationType) uintptr { + rowCopy := *row unicastAddressChangeMutex.Lock() for cb := range unicastAddressChangeCallbacks { - go cb.cb(notificationType, row) + go cb.cb(notificationType, &rowCopy) } unicastAddressChangeMutex.Unlock() return 0 -- cgit v1.2.3-59-g8ed1b