Fix hard crashes in Polygon and Polyline modules.