Caused by 396ad5db83
It is possible that some edge collapsing of non-manifold mesh will
eventually result in extra wire edges, and loose vertices. This was
not properly handled in the boundary checks, assuming that all
modifications preserve mesh manifold.
This fix avoids the crash by adding nullptr check in the boundary
check.
While this is not fully ideal from the result perspective, it is
a safe change for 4.2. Ideally the wire edges and loose vertices
will be removed, but this is a bigger and more risky change. Also,
in Blender 4.0 it was possible to generate loose geometry in
dyntopo as well, so it just a general improvement to happen (and not
a regression).
Pull Request: https://projects.blender.org/blender/blender/pulls/124236