Memory leak on LightFactory when IP not legal
OriNachum opened this issue · comments
Ori Nachum commented
I found an issue when trying to generate a light with an illegal IP. This can happen when there are non-bulbs, or network issues, and the attempt to create a Light fails.
It can be solved by test-catch on await communicator + new Light lines:
try
{
var payload = await communicator
.CommunicateAsync<StateVersionResponsePayload>(request, cancellationToken)
.ConfigureAwait(false);
light = new Light(address, payload.Product, payload.Version, communicator, requestFactory);
return light;
}
catch (Exception ex)
{
communicator.Dispose();
throw;
}
Ollie Day commented
Good find!
I've pushed v1.0.1 with this fix to NuGet.
Thanks!