[FIX] Geometry functions are vulnerable to segfaults from bad user parameters

Fixed #288