MantisBT - VTK
View Issue Details
0014671VTK(No Category)public2014-04-08 09:542015-01-09 13:39
Dr. Frank Heimes 
Sean McBride 
normalminorhave not tried
closedfixed 
6.0.0 
6.2.0 
Kitware
crash
0014671: Null pointer dereference in ~vtkRenderWindow
At line 125 of file vtkRenderWindow.cxx
The command this->PainterDeviceAdapter->Delete(); causes a null pointer dereference, because this->PainterDeviceAdapter is null.

Reason:
In line 82, this->PainterDeviceAdapter = vtkPainterDeviceAdapter::New(); yields null, because vtkPainterDeviceAdapter.cxx is designed and documented to do just that.

Fix:

Either 1)
In line 29 of vtkPainterDeviceAdapter.cxx, replace the default macro definition with this:
#ifndef vtkAbstractObjectFactoryNewMacro
#error You must redefine macro vtkAbstractObjectFactoryNewMacro before including this header
#endif

or 2)
In line 123ff of vtkRenderWindow.cxx, prepare the destructor for the null pointer case:

if (Renderers != nullptr)
    Renderers->Delete();

if (PainterDeviceAdapter != nullptr)
    PainterDeviceAdapter->Delete();

BTW.: Is it really necessary to make the code so extraordinary verbose by prefixing all members with "this->"?
hackaton
Issue History
2014-04-08 09:54Dr. Frank HeimesNew Issue
2014-10-01 10:24Sean McBrideAssigned To => Sean McBride
2014-10-01 10:24Sean McBrideStatusbacklog => tabled
2014-10-01 10:31Sean McBrideNote Added: 0033390
2014-10-01 10:31Sean McBrideTag Attached: hackaton
2014-10-01 12:40Berk GeveciStatustabled => backlog
2014-10-01 13:02Sean McBrideNote Added: 0033396
2014-10-01 13:02Sean McBrideStatusbacklog => gerrit review
2014-10-02 09:23Sean McBrideNote Added: 0033418
2014-10-02 09:23Sean McBrideStatusgerrit review => closed
2014-10-02 09:23Sean McBrideResolutionopen => fixed
2014-10-02 09:23Sean McBrideFixed in Version => 6.2.0
2015-01-09 13:38Sean McBrideSource_changeset_attached => VTK master aab8c86a
2015-01-09 13:39Sean McBrideSource_changeset_attached => VTK master 64e66d78

Notes
(0033390)
Sean McBride   
2014-10-01 10:31   
Dr Heimes, seems someone has added a "if (this->PainterDeviceAdapter)" since you filed this. There's no "if (Renderers != nullptr)" defence, but since you proposed it, I guess you have a way to repro it, so I can add it trivially...
(0033396)
Sean McBride   
2014-10-01 13:02   
http://review.source.kitware.com/17303 [^]
(0033418)
Sean McBride   
2014-10-02 09:23   
Merged.