[Bf-blender-cvs] [23b10b549a1] blender2.8: fix use of uninitialized variable

Mike Erwin noreply at git.blender.org
Fri Apr 7 21:11:48 CEST 2017


Commit: 23b10b549a1b7e713abd97dea32483d40d9bb18f
Author: Mike Erwin
Date:   Fri Apr 7 13:48:11 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB23b10b549a1b7e713abd97dea32483d40d9bb18f

fix use of uninitialized variable

Bug crawled in via 2944438e9a276e48d7eabb5bb88ecec9b2f1e7dc as part of custom manipulators.

===================================================================

M	source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c

===================================================================

diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c
index 7d33a82568f..9755d090e8b 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c
@@ -84,18 +84,20 @@ static void manipulator_primitive_draw_geom(
         const float col_inner[4], const float col_outer[4], const int style)
 {
 	float (*verts)[3];
-	float vert_count;
-	unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
+	unsigned int vert_count = 0;
 
 	if (style == MANIPULATOR_PRIMITIVE_STYLE_PLANE) {
 		verts = verts_plane;
 		vert_count = ARRAY_SIZE(verts_plane);
 	}
 
-	immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
-	wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, PRIM_TRIANGLE_FAN);
-	wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, PRIM_LINE_LOOP);
-	immUnbindProgram();
+	if (vert_count > 0) {
+		unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
+		immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+		wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, PRIM_TRIANGLE_FAN);
+		wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, PRIM_LINE_LOOP);
+		immUnbindProgram();
+	}
 }
 
 static void manipulator_primitive_draw_intern(




More information about the Bf-blender-cvs mailing list