Fix issue #601

A segfault were raised when selection or triangle are not valid pointers.
Just test and skip them in that case.