[vtk-developers] vtkDataArrayTemplate.cxx writes out of bounds when malloc fails

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri Jun 20 16:29:04 EDT 2008



Sean McBride wrote:
  > I redid our tests that started the other thread "vtkImageConvolve
> crashes when malloc fails".  I can confirm that when we see crashes
> there, we do indeed pass through this Mac-only case of using malloc/
> memcpy/free instead of realloc.  So indeed OS X's crappy realloc is
> exacerbating our problem.

Indeed, I am not advocating using realloc on Mac due to the broken 
implementation. Infact VTK already uses new|delete on OS X. So, if I am 
not mistaken, Burlen's patch shouldn't make any difference on the Macs.

It's only for most other platforms, where realloc gives us some benefits 
over new|copy|delete that we may want to pause and think before 
committing the changes.

As Burlen had suggested, an easier fix might be to simply throw an 
exception ourselves if the malloc|realloc fails. Thus giving us the 
benefit of using 'new' minus the disadvantages of not using a 'realloc'.

Utkarsh



More information about the vtk-developers mailing list