mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-08-28 21:06:52 -04:00
etw: Fix panic when provider creation fails
There is a cleanup function deferred to remove the provider from the global provider map. However, this function didn't bind the value of provider ahead of time, so when the provider creation returned with nil for provider, we tried to cleanup a nil provider, and panicked.
This commit is contained in:
+2
-2
@@ -130,11 +130,11 @@ func NewProviderWithID(name string, id *guid.GUID, callback EnableCallback) (pro
|
||||
})
|
||||
|
||||
provider = providers.newProvider()
|
||||
defer func() {
|
||||
defer func(provider *Provider) {
|
||||
if err != nil {
|
||||
providers.removeProvider(provider)
|
||||
}
|
||||
}()
|
||||
}(provider)
|
||||
provider.ID = id
|
||||
provider.callback = callback
|
||||
|
||||
|
||||
Reference in New Issue
Block a user