Skip to content

Commit b8c5840

Browse files
committed
vtkOpenGLGPUVolumeRayCastMapper: handle when table size increases
Because the texture table size is now dynamic, it's no longer sufficient to only allocate it when the pointer is NULL. If the texture table has previously been allocated and the computed table size increases, it's necessary to reallocate the table, otherwise a memory error occurs.
1 parent ea39dd4 commit b8c5840

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Rendering/VolumeOpenGL/vtkOpenGLGPUVolumeRayCastMapper.cxx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,8 @@ class vtkOpacityTable: public vtkTextureTable
367367
{
368368
this->Loaded=false;
369369
const int tableSize = this->ComputeTableSize(scalarOpacity);
370-
if(this->Table==0)
371-
{
372-
this->Table= new float[tableSize];
373-
}
370+
delete[] this->Table;
371+
this->Table = new float[tableSize];
374372

375373
scalarOpacity->GetTable(range[0],range[1],tableSize,this->Table);
376374

@@ -523,11 +521,8 @@ class vtkRGBTable: public vtkTextureTable
523521
{
524522
this->Loaded=false;
525523
const int tableSize = this->ComputeTableSize(scalarRGB);
526-
527-
if(this->Table==0)
528-
{
529-
this->Table = new float[tableSize*3];
530-
}
524+
delete[] this->Table;
525+
this->Table = new float[tableSize * 3];
531526

532527
scalarRGB->GetTable(range[0],range[1],
533528
tableSize,

0 commit comments

Comments
 (0)