Setting of a name to a vtkDataArray leads to crash
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
In current version of VTK of vtkDataArray class we have follow implementation of SetName method:
void vtkDataArray::SetName(const char* name) { delete[] this->Name; this->Name = 0; if (name) { int size = static_cast<int>(strlen(name)); this->Name = new char[size+1]; strcpy(this->Name, name); } }
As you can see first step of this method is deleting of a character array, but the action is produced without checking of the pointer of the array (if it is null or not). More over in constructor of the class the pointer are not initialised. So, it is very easy to correct this bug, no more then two extra lines of code.
But it is wonderful, why you do not use std::string or valarray<char> containers instead the way! For this case this bug can not be appeared at all!!
Best regards.