Fixed crash of mask node when mask is not set
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 30 May 2012 14:30:28 +0000 (14:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 30 May 2012 14:30:28 +0000 (14:30 +0000)
source/blender/compositor/operations/COM_MaskOperation.cpp

index e6456e73be3125f18fb5a13a067a9369cbd7bb60..a742306f4401bafd84d78accd97f4b1e1c65d304 100644 (file)
@@ -65,6 +65,9 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers
        if (this->rasterizedMask)
                return this->rasterizedMask;
 
        if (this->rasterizedMask)
                return this->rasterizedMask;
 
+       if (!this->mask)
+               return NULL;
+
        BLI_mutex_lock(getMutex());
        if (this->rasterizedMask == NULL) {
                int width = this->getWidth();
        BLI_mutex_lock(getMutex());
        if (this->rasterizedMask == NULL) {
                int width = this->getWidth();
@@ -101,13 +104,21 @@ void MaskOperation::determineResolution(unsigned int resolution[], unsigned int
 
 void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
 
 void MaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
 {
-       float *buffer = (float*) data;
-       int index = (y * this->getWidth() + x);
+       if (!data) {
+               color[0] = 0;
+               color[1] = 0;
+               color[2] = 0;
+               color[3] = 1.0f;
+       }
+       else {
+               float *buffer = (float*) data;
+               int index = (y * this->getWidth() + x);
 
 
-       color[0] = buffer[index];
-       color[1] = buffer[index];
-       color[2] = buffer[index];
-       color[3] = 1.0f;
+               color[0] = buffer[index];
+               color[1] = buffer[index];
+               color[2] = buffer[index];
+               color[3] = 1.0f;
+       }
 }
 
 
 }