From b34704267a474e64d05e75c127f8bcc852c46c96 Mon Sep 17 00:00:00 2001 From: Bill Lorensen <bill.lorensen@gmail.com> Date: Thu, 20 Feb 2014 11:06:14 -0500 Subject: [PATCH] BUG: CreateDefaultLookupTable crashes if Input is NULL. TestSetGet.tcl segfaulted when calling GetLookupTable(). GetLookupTable() calls CreateDefaultLookupTable() which requires a non NULL Input. Change-Id: I615ec5b386d75d5b64f636156d0006ed15e093a0 --- Charts/Core/vtkPlotBox.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Charts/Core/vtkPlotBox.cxx b/Charts/Core/vtkPlotBox.cxx index 08559f25f6c..e6b80dc6173 100644 --- a/Charts/Core/vtkPlotBox.cxx +++ b/Charts/Core/vtkPlotBox.cxx @@ -387,18 +387,22 @@ void vtkPlotBox::SetColumnColor(const vtkStdString& colName, double *rgb) //----------------------------------------------------------------------------- void vtkPlotBox::CreateDefaultLookupTable() { - if (this->LookupTable) + // There must be an input to create a lookup table + if (this->GetInput()) { - this->LookupTable->UnRegister(this); + if (this->LookupTable) + { + this->LookupTable->UnRegister(this); + } + vtkLookupTable* lut = vtkLookupTable::New(); + this->LookupTable = lut; + // Consistent Register/UnRegisters. + this->LookupTable->Register(this); + this->LookupTable->Delete(); + vtkTable *table = this->GetInput(); + lut->SetNumberOfColors(table->GetNumberOfColumns()); + this->LookupTable->Build(); } - vtkLookupTable* lut = vtkLookupTable::New(); - this->LookupTable = lut; - // Consistent Register/UnRegisters. - this->LookupTable->Register(this); - this->LookupTable->Delete(); - vtkTable *table = this->GetInput(); - lut->SetNumberOfColors(table->GetNumberOfColumns()); - this->LookupTable->Build(); } //----------------------------------------------------------------------------- -- GitLab