Fix T40482: Cycles matlib file crashes
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Jun 2014 20:29:48 +0000 (02:29 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Jun 2014 20:33:21 +0000 (02:33 +0600)
it's possible that runtime optimizer would call get_attribute
with NULL renderstate. As per documentation, it's valid to
return false in that cases and in worst case we'll just miss
some possible optimization.

Supporting such cases would require some bigger changes to
Cycles since attributes are only set to up for the kernel
after shader compilation.

Thanks Brecht for review!

intern/cycles/kernel/osl/osl_services.cpp

index dba2b66faff66889fafe55dc7a01d4218b10cc6d..8fe48b9b38ce3238f2cb400242623100626ab165 100644 (file)
@@ -754,6 +754,9 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
 bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustring object_name,
                                       TypeDesc type, ustring name, void *val)
 {
+       if (renderstate == NULL)
+               return false;
+
        ShaderData *sd = (ShaderData *)renderstate;
        KernelGlobals *kg = sd->osl_globals;
        bool is_curve;