[vtkusers] vtkXMLDataElement::RemoveAttribute pointer error

shintaro akiyama sntaki at gmail.com
Fri Jul 31 11:46:26 EDT 2009


hello, vtkXMLDataElement::RemoveAttribute have pointer error.
and diffuse statement.

--- vtkXMLDataElement.cxx     2008-11-20 17:08:08.000000000 +0900
+++ vtkXMLDataElement.cxx     2009-08-01 00:30:23.181167700 +0900
@@ -91,15 +91,14 @@
     {
     if(!strcmp(this->AttributeNames[i], name))
       {
+      delete [] this->AttributeNames[i];
+      delete [] this->AttributeValues[i];
       // Shift the other attributes
       for (j = i; j < this->NumberOfAttributes - 1; ++j)
         {
         this->AttributeNames[j] = this->AttributeNames[j + 1];
         this->AttributeValues[j] = this->AttributeValues[j + 1];
         }
-      // Delete the last one
-      delete [] this->AttributeNames[this->NumberOfAttributes - 1];
-      delete [] this->AttributeValues[this->NumberOfAttributes - 1];
       --this->NumberOfAttributes;
       // this->AttributesSize is unchanged
       return;
@@ -223,12 +222,8 @@
     char **newAttributeValues = new char* [newSize];
     for(i = 0; i < this->NumberOfAttributes; ++i)
       {
-      newAttributeNames[i] = new char [strlen(this->AttributeNames[i]) + 1];
-      strcpy(newAttributeNames[i], this->AttributeNames[i]);
-      delete [] this->AttributeNames[i];
-      newAttributeValues[i] = new char [strlen(this->AttributeValues[i]) + 1];
-      strcpy(newAttributeValues[i], this->AttributeValues[i]);
-      delete [] this->AttributeValues[i];
+      newAttributeNames[i] = this->AttributeNames[i];
+      newAttributeValues[i] = this->AttributeValues[i];
       }
     delete [] this->AttributeNames;
     delete [] this->AttributeValues;


--
Shintaro AKIYAMA



More information about the vtkusers mailing list