Commit a3761161 authored by Zack Galbreath's avatar Zack Galbreath
Browse files

prevent segmentation fault

This commit resolves a bug within
vtkOpenGLContextDevice2D::Private::TextureFromImage
that can potentially cause a segmentation fault.

This error occurred when I attempted to draw a 1D horizontal texture
using OpenGL v1.

Until my recent work on vtkColorLegend, this bug remained hidden
because the only tests covering this function used either a 2D
square texture or a 1D vertical texture.

Change-Id: If4e39b2216a074e37c20611c0c8412e18c2689e3
parent 3eba81ad
......@@ -401,12 +401,12 @@ public:
{
if (i < size[0] && j < size[1])
{
dataPtr[i * newImg[0] * bytesPerPixel + j * bytesPerPixel + k] =
origPtr[i * size[0] * bytesPerPixel + j * bytesPerPixel + k];
dataPtr[i * bytesPerPixel + j * newImg[0] * bytesPerPixel + k] =
origPtr[i * bytesPerPixel + j * size[0] * bytesPerPixel + k];
}
else
{
dataPtr[i * newImg[0] * bytesPerPixel + j * bytesPerPixel + k] =
dataPtr[i * bytesPerPixel + j * newImg[0] * bytesPerPixel + k] =
k == 3 ? 0 : 255;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment