Fix usage of uninialized memory in some operations

- FastGaussianBlurValueOperation is a value operation, so use only first vector
  component in initializeTileData.

- Gamma correct/uncorrect operations didn't set alpha for output which lead to
  usage of uninitialzied memory further in nodes graph.
This commit is contained in:
Sergey Sharybin 2012-11-23 12:50:59 +00:00
parent 12f31472d6
commit 587067b4fc
2 changed files with 4 additions and 2 deletions

@ -281,7 +281,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
float *src = newBuf->getBuffer();
float *dst = copy->getBuffer();
for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) {
for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) {
if (*src < *dst) {
*dst = *src;
}
@ -290,7 +290,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
float *src = newBuf->getBuffer();
float *dst = copy->getBuffer();
for (int i = copy->getWidth() * copy->getHeight() * COM_NUMBER_OF_CHANNELS; i != 0; i--, src++, dst++) {
for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) {
if (*src > *dst) {
*dst = *src;
}

@ -48,6 +48,7 @@ void GammaCorrectOperation::executePixel(float output[4], float x, float y, Pixe
output[0] = inputColor[0] > 0.0f ? inputColor[0] * inputColor[0] : 0.0f;
output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f;
output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f;
output[3] = inputColor[3];
if (inputColor[3] > 0.0f) {
output[0] *= inputColor[3];
@ -86,6 +87,7 @@ void GammaUncorrectOperation::executePixel(float output[4], float x, float y, Pi
output[0] = inputColor[0] > 0.0f ? sqrtf(inputColor[0]) : 0.0f;
output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f;
output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f;
output[3] = inputColor[3];
if (inputColor[3] > 0.0f) {
output[0] *= inputColor[3];