[Bf-blender-cvs] [b2dc0e6970e] master: Fix T53978: Bad memory access after recent fix to BSDF mixing
Mai Lavelle
noreply at git.blender.org
Fri Feb 2 02:04:11 CET 2018
Commit: b2dc0e6970e08c798a76c39470eed5a61f5ec9cb
Author: Mai Lavelle
Date: Thu Feb 1 19:59:22 2018 -0500
Branches: master
https://developer.blender.org/rBb2dc0e6970e08c798a76c39470eed5a61f5ec9cb
Fix T53978: Bad memory access after recent fix to BSDF mixing
Added proper checks after BSDF allocation and cleaned up existing
inline checks.
Was introduced in 7261d675e6aeb1b0dff
===================================================================
M intern/cycles/kernel/osl/osl_closures.cpp
===================================================================
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp
index c52230de86e..8acab1ab558 100644
--- a/intern/cycles/kernel/osl/osl_closures.cpp
+++ b/intern/cycles/kernel/osl/osl_closures.cpp
@@ -208,7 +208,11 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
- sd->flag |= (bsdf) ? bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd) : 0;
+ if(!bsdf) {
+ return;
+ }
+
+ sd->flag |= bsdf_microfacet_ggx_clearcoat_setup(bsdf, sd);
}
};
@@ -391,9 +395,13 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_y = bsdf->alpha_x;
- sd->flag |= (bsdf) ? bsdf_microfacet_ggx_fresnel_setup(bsdf, sd) : 0;
+ sd->flag |= bsdf_microfacet_ggx_fresnel_setup(bsdf, sd);
}
};
@@ -417,7 +425,11 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
- sd->flag |= (bsdf) ? bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd) : 0;
+ if(!bsdf) {
+ return;
+ }
+
+ sd->flag |= bsdf_microfacet_ggx_aniso_fresnel_setup(bsdf, sd);
}
};
@@ -478,10 +490,14 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->ior = 0.0f;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_y = bsdf->alpha_x;
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_setup(bsdf) : 0;
+ sd->flag |= bsdf_microfacet_multi_ggx_setup(bsdf);
}
};
@@ -503,8 +519,12 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->ior = 0.0f;
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_aniso_setup(bsdf) : 0;
+ sd->flag |= bsdf_microfacet_multi_ggx_aniso_setup(bsdf);
}
};
@@ -530,9 +550,13 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_y = bsdf->alpha_x;
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_glass_setup(bsdf) : 0;
+ sd->flag |= bsdf_microfacet_multi_ggx_glass_setup(bsdf);
}
};
@@ -591,9 +615,13 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_y = bsdf->alpha_x;
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd) : 0;
+ sd->flag |= bsdf_microfacet_multi_ggx_fresnel_setup(bsdf, sd);
}
};
@@ -617,7 +645,11 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd) : 0;
+ if(!bsdf) {
+ return;
+ }
+
+ sd->flag |= bsdf_microfacet_multi_ggx_aniso_fresnel_setup(bsdf, sd);
}
};
@@ -645,9 +677,13 @@ public:
void setup(ShaderData *sd, int path_flag, float3 weight)
{
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
+ if(!bsdf) {
+ return;
+ }
+
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
bsdf->alpha_y = bsdf->alpha_x;
- sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_glass_fresnel_setup(bsdf, sd) : 0;
+ sd->flag |= bsdf_microfacet_multi_ggx_glass_fresnel_setup(bsdf, sd);
}
};
@@ -720,7 +756,11 @@ public:
volume_extinction_setup(sd, weight);
HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc_osl(sd, sizeof(HenyeyGreensteinVolume), weight, ¶ms);
- sd->flag |= (volume) ? volume_henyey_greenstein_setup(volume) : 0;
+ if(!volume) {
+ return;
+ }
+
+ sd->flag |= volume_henyey_greenstein_setup(volume);
}
};
More information about the Bf-blender-cvs
mailing list