OllieDay / Lifx

Library for controlling LIFX Wi-Fi Smart LED devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak on LightFactory when IP not legal

OriNachum opened this issue · comments

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;
		}

Good find!

I've pushed v1.0.1 with this fix to NuGet.

Thanks!