When one ore more octets are missing the Span<byte> buffer = stackalloc byte[4]; line fills it with zeroes, therefore covers the error.
When one or more octets are extra, for (int i = 0, j = parts.Length - 3; (i < 4) && (j > -1); i++, j--) loop covers as it ignores the extras.
I added an explicit guard clause for IPv4 addresses.