diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-13 19:43:14 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-18 18:24:20 +0300 |
commit | 0fa5c0df74914023eaf2944b8a2fcb46b52e38f7 (patch) | |
tree | d1e8bff806b331e0db831bd61448dd122a22bd94 /intern | |
parent | 2dc4c07d3a20ef30796e2a20737215cc93383a30 (diff) |
Cycles: Solve possible buffer overrun when using too much closures
Glass BSDF was doing some magic with copying weigths from initial closure
onto refraction one and the code was not checking properly for the number
of closures.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/svm/svm_closure.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h index 7cdcbc2d30c..20a6cb8cd45 100644 --- a/intern/cycles/kernel/svm/svm_closure.h +++ b/intern/cycles/kernel/svm/svm_closure.h @@ -285,15 +285,17 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float * #endif /* refraction */ - sc = ccl_fetch_array(sd, closure, ccl_fetch(sd, num_closure)); - sc->weight = weight; - sc->sample_weight = sample_weight; + if(ccl_fetch(sd, num_closure) < MAX_CLOSURE) { + sc = ccl_fetch_array(sd, closure, ccl_fetch(sd, num_closure)); + sc->weight = weight; + sc->sample_weight = sample_weight; - sc = svm_node_closure_get_bsdf(sd, mix_weight*(1.0f - fresnel)); + sc = svm_node_closure_get_bsdf(sd, mix_weight*(1.0f - fresnel)); - if(sc) { - sc->N = N; - svm_node_glass_setup(sd, sc, type, eta, roughness, true); + if(sc) { + sc->N = N; + svm_node_glass_setup(sd, sc, type, eta, roughness, true); + } } break; |