Commit: f24ad274cb3002f380aa206c07ca564711bba089
Author: Brecht Van Lommel
Date: Fri Nov 5 20:05:08 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rBf24ad274cb3002f380aa206c07ca564711bba089
Fix T92503: Cycles OSL crash with object attributes
Can't cast to float4 because it might not have correct alignment.
===================================================================
M intern/cycles/kernel/osl/services.cpp
===================================================================
diff --git a/intern/cycles/kernel/osl/services.cpp
b/intern/cycles/kernel/osl/services.cpp
index ca0a5a068b3..389c1e2b746 100644
--- a/intern/cycles/kernel/osl/services.cpp
+++ b/intern/cycles/kernel/osl/services.cpp
@@ -832,16 +832,21 @@ static bool get_object_attribute(const
OSLGlobals::Attribute &attr,
{
if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) {
- return set_attribute_float3(*(float3 *)attr.value.data(), type,
derivatives, val);
+ const float *data = (const float *)attr.value.data();
+ return set_attribute_float3(make_float3(data[0], data[1], data[2]), type,
derivatives, val);
}
else if (attr.type == TypeFloat2) {
- return set_attribute_float2(*(float2 *)attr.value.data(), type,
derivatives, val);
+ const float *data = (const float *)attr.value.data();
+ return set_attribute_float2(make_float2(data[0], data[1]), type,
derivatives, val);
}
else if (attr.type == TypeDesc::TypeFloat) {
- return set_attribute_float(*(float *)attr.value.data(), type, derivatives,
val);
+ const float *data = (const float *)attr.value.data();
+ return set_attribute_float(data[0], type, derivatives, val);
}
else if (attr.type == TypeRGBA || attr.type == TypeDesc::TypeFloat4) {
- return set_attribute_float4(*(float4 *)attr.value.data(), type,
derivatives, val);
+ const float *data = (const float *)attr.value.data();
+ return set_attribute_float4(
+ make_float4(data[0], data[1], data[2], data[3]), type, derivatives,
val);
}
else if (attr.type == type) {
size_t datasize = attr.value.datasize();
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs