diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2018-02-02 03:59:22 +0300 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2018-02-02 04:03:29 +0300 |
commit | b2dc0e6970e08c798a76c39470eed5a61f5ec9cb (patch) | |
tree | 1718d6ff7d3b05c4e0f9f6db662747e30b897748 /intern/cycles | |
parent | 78a77fe622b86fb9b477d10533729a7889b3e115 (diff) |
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
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/osl/osl_closures.cpp | 60 |
1 files changed, 50 insertions, 10 deletions
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); } }; |