Skip to content

Commit 634a33b

Browse files
msmolensalvarosan
authored andcommitted
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 608d4fb commit 634a33b

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
@@ -368,10 +368,8 @@ class vtkOpacityTable: public vtkTextureTable
368368
{
369369
this->Loaded=false;
370370
const int tableSize = this->ComputeTableSize(scalarOpacity);
371-
if(this->Table==0)
372-
{
373-
this->Table= new float[tableSize];
374-
}
371+
delete[] this->Table;
372+
this->Table = new float[tableSize];
375373

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

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

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

0 commit comments

Comments
 (0)