Fix for #3789, segfault in _tri
Merge pull request #3797 from ianthomas23/3789_segfault

Fix for #3789, segfault in _tri