[vtkusers] segfault during opening buggy OBJ file

Mihail Isakov mihail.isakov at googlemail.com
Tue Aug 8 11:00:52 EDT 2017


Hello,
how i could avoid segmentation fault during processing of buggy OBJ file?
VTK version is 7.1.1, unfortunately VTK 8.0.0 is currently not an option for me,
i have to support older compilers, so i have not tested VTK 8.0.0.

-------------------------------------------------------------------
#include <vtkSmartPointer.h>
#include <vtkOBJReader.h>
#include <vtkPolyData.h>
#include <vtkPolyDataNormals.h>

int main(int argc, char * argv[])
{
  vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
  reader->SetFileName(argv[1]);
  reader->Update();
  vtkSmartPointer<vtkPolyDataNormals> normals =
vtkSmartPointer<vtkPolyDataNormals>::New();
  normals->SetInputConnection(reader->GetOutputPort());
  normals->Update();
  return 0;
}
-------------------------------------------------------------------

r at deb:~/test0/build$ ./test0 ../vhmale_1024_skel_tri_1_gf_1.obj
Segmentation fault

Crash is here: VTK-7.1.1/Common/DataModel/vtkCellLinks.h

 193 inline void vtkCellLinks::InsertCellReference(vtkIdType ptId,
 194                                               unsigned short pos,
 195                                               vtkIdType cellId)
 196 {
 197   this->Array[ptId].cells[pos] = cellId; <------------------
 198 }

Min. project with OBJ file is here:

https://drive.google.com/file/d/0ByBLJ2-U1t9xODZHeThSWnpkaEk/view?usp=sharing


Important were just to avoid crash somehow...
Thank you.

Regards,
Mihail


More information about the vtkusers mailing list