<div dir="ltr">On Thu, Apr 21, 2016 at 1:12 PM, David Lonie <<a href="mailto:david.lonie@kitware.com">david.lonie@kitware.com</a>> wrote:<br>> 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.<br><br><div>I just checked the behavior of the old implementation:</div><div><br></div><div><div><font face="monospace, monospace">//---------------------------------------------------</font></div><div><font face="monospace, monospace">// Release storage and reset array to initial state.</font></div><div><font face="monospace, monospace">template <class T></font></div><div><font face="monospace, monospace">void vtkDataArrayTemplate<T>::Initialize()</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace">  this->DeleteArray();</font></div><div><font face="monospace, monospace">  this->Array = 0;</font></div><div><font face="monospace, monospace">  this->Size = 0;</font></div><div><font face="monospace, monospace">  this->MaxId = -1;</font></div><div><font face="monospace, monospace">  this->DataChanged();</font></div><div><font face="monospace, monospace">}</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">and </font></div><div><font face="monospace, monospace"><br></font></div><div><span style="font-family:monospace">T* GetPointer(vtkIdType id) { return this->Array + id; }</span><br></div><div><font face="monospace"><br></font></div><div><font face="monospace, monospace">Looks like 'dataArray->Initialize(); return dataArray->GetPointer(0);' would always return NULL, even for the old implementation.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace">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.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Dave</font></div></div>