Skip to content

Fill panics if passed the same network #3

Description

@markgardner10
foundSubnets, _ := netaddr.NewIPv4NetList([]string{"10.0.0.0/16"})

supernet, _ := netaddr.ParseIPv4Net("10.0.0.0/16")

filled := supernet.Fill(foundSubnets) // panics because foundSubnets is the same as the supernet 10.0.0.0/16
func (net *IPv4Net) Fill(list IPv4NetList) IPv4NetList {
	var subs IPv4NetList
	// get rid of non subnets
	if list != nil && len(list) > 0 {
		for _, e := range list {
			isRel, rel := net.Rel(e)
			if isRel && rel == 1 { // changing this too ---> isRel && rel == 1 || isRel && rel == 0
				subs = append(subs, e)
			}
		}
		// discard subnets of subnets & sort
		subs = subs.discardSubnets().Sort() // <-------- panics here becasue subs is empty slice, 
	} else {
		return subs
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions