Hi!
Moving the check into the digit loop, as
getbits() already does for IPv6, is the right fix IMO.
One minor comment, not a blocker: the IPv6 path
rejects leading zeros in the prefix length
(getbits() returns 0 for inputs like '::1/024', due to the
"no leading zeros" check); maybe do the same for IPv4?
--
Best regards,
Roman Khapov