[vtk-developers] vtkImageConvolve crashes when malloc fails
mcoursolle at rogue-research.com
Tue Jun 3 16:20:37 EDT 2008
Hi VTK developers,
I am performing a series of filters, where some of them are
My input vtkImageData is usually close to 100Mbytes, and the execution
of my pipeline
seems to cause some memory fragmentation. Therefore, malloc will
eventually fail, causing
a crash in vtkImageConvolve.
If malloc fails during the execution of a pipeline, then the
scalarPointer of the resulting vtkImageData is NULL. If a connected
vtkImageConvolve filter receives such a vtkImageData
as its input, it tries to access the scalar pointer (which is NULL),
causing a crash.
A solution would be to check the pointers:
// ADDED CODE BEGIN--------
// Make sure the scalar pointers are valid.
if (!inData->GetScalarPointer() || !outData-
vtkErrorMacro(<< "Execute: input and/or output image does not have
any scalar value.");
// ADDED CODE END--------
static_cast<VTK_TT *>(inPtr), outData,
outExt, id, inInfo));
vtkErrorMacro(<< "Execute: Unknown ScalarType");
So I was wondering,
1) Is that the right way to avoid such crashes?
2) I guess that problem might occur with other filters as well...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtk-developers