jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
368 stars 71 forks source link

.Contains broken when using Mask Length constuctor #64

Closed richardlawley closed 4 years ago

richardlawley commented 4 years ago

This was broken in 4.1.0 by 4f756998fc6d851a576531af91fdcc22af788d07. Most constructors had the following line added:

Operator = RangeOperatorFactory.Create(this);

This was missed in the mask length constructor: new IPAddressRange(IPAddress.Parse("10.0.0.0", 24))

This causes .Contains to throw NullReferenceException:

var range = new IPAddressRange(IPAddress.Parse("192.168.0.80"), 24);
range.Contains(range.Begin).Is(true);         // throws NullReferenceException