don't crash when measuring faulty geometry (fixes partially #7991)