[vtk-developers] Small Bug in vtkSetStringMacro ?

Roland roland.schwarz at chello.at
Sun Nov 2 09:33:56 EST 2003


In the vtkSetStringMacro there seems to be a small Bug.

When the Debug flag is on the argument _arg will be sent to the ostream. This is not bad until the macro is beeing called with _arg == NULL. This seems to be the case i.e. in the destructor of  vtkXMLWriter.

The following is from Common/vtkSetGet.h :

#define vtkSetStringMacro(name) \
virtual void Set##name (const char* _arg) \
  { \
  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << _arg ); \
  if ( this->name == NULL && _arg == NULL) { return;} \
  if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
  if (this->name) { delete [] this->name; } \
  if (_arg) \
    { \
    this->name = new char[strlen(_arg)+1]; \
    strcpy(this->name,_arg); \
    } \
   else \
    { \
    this->name = NULL; \
    } \
  this->Modified(); \
  } 

Best regards,
Roland






More information about the vtk-developers mailing list