MantisBT - VTK
View Issue Details
0012149VTK(No Category)public2011-05-04 03:342013-12-12 23:27
John Stark. 
Robert Maynard 
normalminoralways
closedfixed 
 
6.0.0 
0012149: vtkDataReader: leaks memory in IsFileValid
Not all return paths from the function given below result in the file being closed.
int vtkDataReader::IsFileValid(const char *dstype)
This results in a leak of a std::istream object (m_IS) every time the function is called on a broad set of files.
Call vtkDataReader::IsFileValid with a file that does not contain "dataset" on the first line. Observe that this->CloseVTKFile() is not called.
To fix, add
this->CloseVTKFile();
just before the return 0; from this function.

And / Or
Always delete the existing m_IS in vtkDataReader::OpenVTKFile();

No tags attached.
Issue History
2011-05-04 03:34John Stark.New Issue
2011-05-04 07:13John Stark.Note Added: 0026429
2011-05-04 07:51David PartykaAssigned To => Robert Maynard
2011-05-04 07:51David PartykaStatusbacklog => tabled
2011-06-16 13:12Zack GalbreathCategoryDevelopment => (No Category)
2011-08-25 04:40Benoit BleuzeNote Added: 0027427
2011-11-30 04:10John StarkNote Added: 0027747
2013-12-12 23:27Dave DeMarleNote Added: 0031926
2013-12-12 23:27Dave DeMarleStatusbacklog => closed
2013-12-12 23:27Dave DeMarleResolutionopen => fixed
2013-12-12 23:27Dave DeMarleFixed in Version => 6.0.0

Notes
(0026429)
John Stark.   
2011-05-04 07:13   
Also, in the same function, the following test needs to be split:
  if (!this->OpenVTKFile() || !this->ReadHeader() )
    {
    return 0;
    }

In the case the file is opened, the file needs to be closed even if ReadHeader fails, to give
  if (!this->OpenVTKFile())
    {
    return 0;
    }

  if ( !this->ReadHeader() )
    {
    this->CloseVTKFile ();
    return 0;
    }
(0027427)
Benoit Bleuze   
2011-08-25 04:40   
Hi there,
I just also noticed this issue, is there any news on the matter?
It is quite an easy fix, and the reporter provided a solution, but I think I haven't seen any change on the git repos so far.

Thank you for any updates.
(0027747)
John Stark   
2011-11-30 04:10   
Submitted patch to gerrit :
http://review.source.kitware.com/#change,3405 [^]
(0031926)
Dave DeMarle   
2013-12-12 23:27   
commit 46514f9 merged pre 6.0.0