Cycles: Fix uninitialized memory access when comparing curve mapping nodes
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 4 Apr 2017 11:47:18 +0000 (13:47 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 4 Apr 2017 13:43:12 +0000 (15:43 +0200)
The issue is coming from the fact that float3 is actually 16 bytes aligned
data type and the "padding" was not initialized. This caused memcmp() to
access non-initialized memory.

intern/cycles/blender/blender_util.h

index 4d57533052076277dfcd81672a55c345599df164..abdbb6be0fd25ed7ec61a7c5217b9aead8a17663 100644 (file)
@@ -174,22 +174,19 @@ static inline void curvemapping_color_to_array(BL::CurveMapping& cumap,
 
        if(rgb_curve) {
                BL::CurveMap mapI = cumap.curves[3];
-
                for(int i = 0; i < size; i++) {
-                       float t = min_x + (float)i/(float)(size-1) * range_x;
-
-                       data[i][0] = mapR.evaluate(mapI.evaluate(t));
-                       data[i][1] = mapG.evaluate(mapI.evaluate(t));
-                       data[i][2] = mapB.evaluate(mapI.evaluate(t));
+                       const float t = min_x + (float)i/(float)(size-1) * range_x;
+                       data[i] = make_float3(mapR.evaluate(mapI.evaluate(t)),
+                                             mapG.evaluate(mapI.evaluate(t)),
+                                             mapB.evaluate(mapI.evaluate(t)));
                }
        }
        else {
                for(int i = 0; i < size; i++) {
                        float t = min_x + (float)i/(float)(size-1) * range_x;
-
-                       data[i][0] = mapR.evaluate(t);
-                       data[i][1] = mapG.evaluate(t);
-                       data[i][2] = mapB.evaluate(t);
+                       data[i] = make_float3(mapR.evaluate(t),
+                                             mapG.evaluate(t),
+                                             mapB.evaluate(t));
                }
        }
 }