MantisBT - VTK
View Issue Details
0013908VTK(No Category)public2013-02-26 17:592013-04-05 18:56
Micah Chambers 
Berk Geveci 
normalminorhave not tried
closedfixed 
 
 
TBD
performance
0013908: Memory Leak in the following code
vtkDataReader.cxx has a memory leak here: 'decoded' is allocated but never deleted. Line 1749 of the git version.

    else
      {
      // read in newline
      vtkStdString s;
      my_getline(*(this->IS), s);

      for (int i=0; i<numTuples; i++)
        {
        for (int j=0; j<numComp; j++)
          {
          my_getline(*(this->IS), s);
          int length = static_cast<int>(s.length());
          char* decoded = new char[length + 1];
          int decodedLength = this->DecodeString(decoded, s.c_str());
          vtkStdString decodedStr(decoded, decodedLength);
          ((vtkStringArray*)array)->InsertNextValue(decodedStr);
          }
        }
      }
    }
No tags attached.
patch vtkDataReader.patch (936) 2013-02-26 18:16
https://www.vtk.org/Bug/file/9400/vtkDataReader.patch
? testcorr.vtk (290,635) 2013-02-26 18:28
https://www.vtk.org/Bug/file/9401/testcorr.vtk
Issue History
2013-02-26 17:59Micah ChambersNew Issue
2013-02-26 18:06Jean-Christophe Fillion-RobinNote Added: 0030388
2013-02-26 18:16Micah ChambersFile Added: vtkDataReader.patch
2013-02-26 18:16Micah ChambersNote Added: 0030389
2013-02-26 18:28Micah ChambersFile Added: testcorr.vtk
2013-02-26 18:28Micah ChambersNote Added: 0030390
2013-03-02 20:21Berk GeveciAssigned To => Berk Geveci
2013-03-02 20:21Berk GeveciStatusbacklog => tabled
2013-03-02 20:22Berk GeveciNote Added: 0030398
2013-03-02 20:22Berk GeveciStatustabled => customer review
2013-03-02 20:22Berk GeveciResolutionopen => fixed
2013-04-05 18:56Berk GeveciStatuscustomer review => closed

Notes
(0030388)
Jean-Christophe Fillion-Robin   
2013-02-26 18:06   
Hi Micah,

Thanks for pointing this out. Would be great if you could submit a patch that would be discussed by the community :)

See http://www.vtk.org/Wiki/VTK/Git/Develop [^]
(0030389)
Micah Chambers   
2013-02-26 18:16   
Yeah I'm testing the patch now...
(0030390)
Micah Chambers   
2013-02-26 18:28   
Yeah, ran valgrind on my code and it works. I don't have sample code though, because its part of kind of a big codebase. I will however attach a sample dataset where the bug occurs. Reading the dataset with vtkDataSetReader will definitely recreate the bug. While I was there I went ahead and added delete[] to several other 'decoded' variables. I think this was a copy-and-paste error.
(0030398)
Berk Geveci   
2013-03-02 20:22   
Committed a fix for this to Gerrit review. Please see

http://review.source.kitware.com/#/t/2278 [^]

Feel free to register to Gerrit and comment.