Commit 0664ec35 authored by Berk Geveci's avatar Berk Geveci Committed by Code Review
Browse files

Merge topic 'dataset-surface-fix' into master

3978a87e Fixed issue in filter leading to sanitizer errors.
parents 0dec660c 3978a87e
......@@ -52,8 +52,18 @@
static inline int sizeofFastQuad(int numPts)
{
// account for size of ptArray
return static_cast<int>(sizeof(vtkFastGeomQuad)+(numPts-4)*sizeof(vtkIdType));
const int qsize = sizeof(vtkFastGeomQuad);
const int sizeId = sizeof(vtkIdType);
// If necessary, we create padding after vtkFastGeomQuad such that
// the beginning of ids aligns evenly with sizeof(vtkIdType).
if (qsize % sizeId == 0)
{
return static_cast<int>(qsize+numPts*sizeId);
}
else
{
return static_cast<int>((qsize/sizeId+1+numPts)*sizeId);
}
}
class vtkDataSetSurfaceFilter::vtkEdgeInterpolationMap
......@@ -2315,6 +2325,19 @@ vtkFastGeomQuad* vtkDataSetSurfaceFilter::NewFastGeomQuad(int numPts)
(this->FastGeomQuadArrays[this->NextArrayIndex] + this->NextQuadIndex);
q->numPts = numPts;
const int qsize = sizeof(vtkFastGeomQuad);
const int sizeId = sizeof(vtkIdType);
// If necessary, we create padding after vtkFastGeomQuad such that
// the beginning of ids aligns evenly with sizeof(vtkIdType).
if (qsize % sizeId == 0)
{
q->ptArray = (vtkIdType*)q + qsize/sizeId;
}
else
{
q->ptArray = (vtkIdType*)q + qsize/sizeId + 1;
}
this->NextQuadIndex += polySize;
return q;
......
......@@ -40,7 +40,7 @@ struct vtkFastGeomQuadStruct
struct vtkFastGeomQuadStruct *Next;
vtkIdType SourceId;
int numPts;
vtkIdType ptArray[4]; // actually a variable length array. MUST be last
vtkIdType* ptArray;
};
typedef struct vtkFastGeomQuadStruct vtkFastGeomQuad;
//ETX
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment