out of bound access in vtkScalarsToColorsUnpackBits
I believe vtkScalarsToColorsUnpackBits is incorrect as the j-loop writes into newPtr[0-7] eventhough newPtr is of size n<8 (only access to newPtr[0-(n-1)] is allowed)
unsigned char* vtkScalarsToColorsUnpackBits(void* inPtr, vtkIdType numValues)
{
vtkIdType n = (numValues + 7) % 8;
unsigned char* newPtr = new unsigned char[n];
unsigned char* tmpPtr = newPtr;
unsigned char* bitdata = static_cast<unsigned char*>(inPtr);
for (vtkIdType i = 0; i < n; i += 8)
{
unsigned char b = *bitdata++;
int j = 8;
do
{
*tmpPtr++ = ((b >> (--j)) & 0x01);
} while (j);
}
return newPtr;
}
maybe j should be initialized to n instead of 8 ?
note that the flow only goes inside the i-loop 0 or 1 time, should it iterate over the inPtr data ?