From c118c7174a6939cbdfd35f9aaaa39c93a30cd452 Mon Sep 17 00:00:00 2001 From: Gregory Graf Date: Sun, 31 May 2015 11:32:38 -0500 Subject: Raise ArgumentError if IP address is nil --- lib/ipaddress/ipv4.rb | 1 + lib/ipaddress/ipv6.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index 7d8e0d3..cbccac0 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -61,6 +61,7 @@ module IPAddress; # IPAddress::IPv4.new "10.0.0.1/255.0.0.0" # def initialize(str) + raise ArgumentError, "Nil IP" unless str ip, netmask = str.split("/") # Check the ip and remove white space diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb index 88098bc..76f8715 100644 --- a/lib/ipaddress/ipv6.rb +++ b/lib/ipaddress/ipv6.rb @@ -87,6 +87,7 @@ module IPAddress; # ip6 = IPAddress "2001:db8::8:800:200c:417a/64" # def initialize(str) + raise ArgumentError, "Nil IP" unless str ip, netmask = str.split("/") if str =~ /:.+\./ -- cgit v1.2.1