fix use of uninitialized variable
authorMike Erwin <significant.bit@gmail.com>
Fri, 7 Apr 2017 17:48:11 +0000 (13:48 -0400)
committerMike Erwin <significant.bit@gmail.com>
Fri, 7 Apr 2017 17:48:11 +0000 (13:48 -0400)
Bug crawled in via 2944438e9a276e48d7eabb5bb88ecec9b2f1e7dc as part of custom manipulators.

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

index 7d33a82568fb0191aaf2f7747e0c37bb349e3004..9755d090e8b05a4dc21e7103ee6f1de241aab1d5 100644 (file)
@@ -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];
         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);
        }
 
 
        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(
 }
 
 static void manipulator_primitive_draw_intern(