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.
This commit is contained in:
Sergey Sharybin 2015-06-13 18:43:14 +02:00
parent 2dc4c07d3a
commit 0fa5c0df74
1 changed files with 9 additions and 7 deletions

View File

@ -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;