Fix a subtle memory reference error in triangle

Transfer memory references after calling triangulate.