Fix #35330: Blur node crash due to size overflow
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 13 May 2013 11:52:04 +0000 (11:52 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 13 May 2013 11:52:04 +0000 (11:52 +0000)
Issue was caused by too hight value used for size,
which came from infinite Z-buffer point.

Solved the crash by clamoing maximal gaussian table
radius to 30K, which seems to be reasonable.

source/blender/compositor/operations/COM_BlurBaseOperation.h
source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp

index d8729ad4394a63002b8aeab56d046655395e0969..a868f0bfa04c3f5e60521d66b76e474398e24d60 100644 (file)
@@ -25,6 +25,8 @@
 #include "COM_NodeOperation.h"
 #include "COM_QualityStepHelper.h"
 
+#define MAX_GAUSSTAB_RADIUS 30000
+
 class BlurBaseOperation : public NodeOperation, public QualityStepHelper {
 private:
 
index aaf5f92505b6a3af17d744a3eaf7cee0b5783e96..af15f719cbc193bf91472a90684fa3e27b9be49b 100644 (file)
@@ -55,8 +55,7 @@ void GaussianAlphaXBlurOperation::initExecution()
 
        if (this->m_sizeavailable) {
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -69,8 +68,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
        if (this->m_gausstab == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -79,8 +77,7 @@ void GaussianAlphaXBlurOperation::updateGauss()
        if (this->m_distbuf_inv == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff);
index 650805f91d566e98a5294a8b31f71b10525d303b..4aee878a8c81179f8555647e37118e2ad5188d76 100644 (file)
@@ -55,8 +55,7 @@ void GaussianAlphaYBlurOperation::initExecution()
 
        if (this->m_sizeavailable) {
                float rad = this->m_size * this->m_data->sizey;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -69,8 +68,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
        if (this->m_gausstab == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizey;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -79,8 +77,7 @@ void GaussianAlphaYBlurOperation::updateGauss()
        if (this->m_distbuf_inv == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff);
index af231d118a688d6a0e35aebeaae3ba3cbcdd10d8..13b749f8b9ce09dad6b364da31a23409b564181d 100644 (file)
@@ -53,8 +53,7 @@ void GaussianXBlurOperation::initExecution()
 
        if (this->m_sizeavailable) {
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -66,8 +65,7 @@ void GaussianXBlurOperation::updateGauss()
        if (this->m_gausstab == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizex;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
index 7bf85a953f4269aac48d27dfaceca35de68f5e8e..0a2e8aeeba807f9c87588ddac9d6491a33676499 100644 (file)
@@ -53,8 +53,7 @@ void GaussianYBlurOperation::initExecution()
 
        if (this->m_sizeavailable) {
                float rad = this->m_size * this->m_data->sizey;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
@@ -66,8 +65,7 @@ void GaussianYBlurOperation::updateGauss()
        if (this->m_gausstab == NULL) {
                updateSize();
                float rad = this->m_size * this->m_data->sizey;
-               if (rad < 1)
-                       rad = 1;
+               CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
 
                this->m_rad = rad;
                this->m_gausstab = BlurBaseOperation::make_gausstab(rad);