Skip to content
Snippets Groups Projects
Commit a69e71b4 authored by 19001248's avatar 19001248 Committed by Robbie Li
Browse files

fix memory leak in vtkSTLReader when vtkSTLReader failed to read STL file

parent f8900800
No related branches found
No related tags found
No related merge requests found
......@@ -125,6 +125,12 @@ int vtkSTLReader::RequestData(
if (!this->ReadASCIISTL(fp, newPts, newPolys, newScalars))
{
fclose(fp);
newPts->Delete();
newPolys->Delete();
if(newScalars)
{
newScalars->Delete();
}
return 0;
}
}
......@@ -137,12 +143,24 @@ int vtkSTLReader::RequestData(
{
vtkErrorMacro(<< "File " << this->FileName << " not found");
this->SetErrorCode(vtkErrorCode::CannotOpenFileError);
newPts->Delete();
newPolys->Delete();
if(newScalars)
{
newScalars->Delete();
}
return 0;
}
if (!this->ReadBinarySTL(fp, newPts, newPolys))
{
fclose(fp);
newPts->Delete();
newPolys->Delete();
if(newScalars)
{
newScalars->Delete();
}
return 0;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment