prevent segfault when parsing empty CIDR
This commit is contained in:
parent
b770d387bf
commit
555ffad58b
@ -18,8 +18,12 @@ func (n JSONIPNet) MarshalJSON() ([]byte, error) {
|
||||
func (n *JSONIPNet) UnmarshalJSON(b []byte) error {
|
||||
cidr := strings.Trim(string(b), "\"")
|
||||
IP, IPNet, err := net.ParseCIDR(cidr)
|
||||
IPNet.IP = IP
|
||||
n.IPNet = *IPNet
|
||||
|
||||
if err == nil {
|
||||
IPNet.IP = IP
|
||||
n.IPNet = *IPNet
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user