Fix an NPE that is thrown when the input geometry is actually null

Quite a huge change :-) Linked to #321