Commit f76e167a authored by Sean McBride's avatar Sean McBride
Browse files

Fixed undefined ptr overflow

Fixed the same UB in 3 tests:

vtkViewsInfovisCxx-TestHierarchicalGraphView
vtkViewsInfovisCxx-TestIconGlyphFilter
vtkViewsInfovisCxx-TestSpanTreeLayoutStrategy

Where GetBuffer() returned 0 and MaxId was -1, resulting in a pointer to 0xFFFFFFFF.  Even though 1 is added right after, it's apparently UB to even have this temporary overflowed pointer. Crazy. Anyway, calculating the offset first seems no worse for readability and correctness.

Found by clang 5 UBSan.
parent 20c4f790
......@@ -372,8 +372,9 @@ void vtkAOSDataArrayTemplate<ValueTypeT>::FillTypedComponent(int compIdx,
template <class ValueTypeT>
void vtkAOSDataArrayTemplate<ValueTypeT>::FillValue(ValueType value)
{
ptrdiff_t offset = this->MaxId + 1;
std::fill(this->Buffer->GetBuffer(),
this->Buffer->GetBuffer() + this->MaxId + 1,
this->Buffer->GetBuffer() + offset,
value);
}
......
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