[vtk-developers] vtkMINCImageAttributes regression in master vs 6.3, related to new vtkDataArray changes?

David Lonie david.lonie at kitware.com
Thu Apr 21 13:18:05 EDT 2016


On Thu, Apr 21, 2016 at 1:12 PM, David Lonie <david.lonie at kitware.com>
wrote:
> I don't think we can even change it to always return a valid pointer.
vtkAbstractArray::Initialize() is documented to 'release storage', which to
me means that there should not be any memory allocated to the array
afterwards. In this case, NULL is the only logical value that can be
returned.

I just checked the behavior of the old implementation:

//---------------------------------------------------
// Release storage and reset array to initial state.
template <class T>
void vtkDataArrayTemplate<T>::Initialize()
{
  this->DeleteArray();
  this->Array = 0;
  this->Size = 0;
  this->MaxId = -1;
  this->DataChanged();
}

and

T* GetPointer(vtkIdType id) { return this->Array + id; }

Looks like 'dataArray->Initialize(); return dataArray->GetPointer(0);'
would always return NULL, even for the old implementation.

I think the proper fix here is to always either check that the array is not
empty before calling GetPointer or explicitly checking the return value.

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160421/7c9b9944/attachment.html>


More information about the vtk-developers mailing list