Unfortunately no. I had this issue some time ago in a rather complex scenario in a project I no longer have access to the code... Well, I think adding that null check I proposed would fix at least the NPE issue without adding any other problem. If a null value for that testPt variable is rather a symptom than the cause I cannot judge with my current knowledge, sorry.
NPE in RayCrossingCounter during polygonize
Prevent NPE in LineDissolver on zero-length edge