fix for 2 errors where the 2d arrays were used as 3d. (out of bounds read).
authorCampbell Barton <ideasman42@gmail.com>
Wed, 13 Mar 2013 18:10:05 +0000 (18:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 13 Mar 2013 18:10:05 +0000 (18:10 +0000)
also minor code cleanup.

source/blender/blenkernel/intern/brush.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/gpu/intern/gpu_extensions.c

index 289086f8b86501ea6cdd951d6b5a941b2a8ccea5..71db2fc56da7a4fa0fba85f19fdedfab7799af0d 100644 (file)
@@ -532,7 +532,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
                /* Get strength by feeding the vertex
                 * location directly into a texture */
                hasrgb = externtex(mtex, point, &intensity,
-                         rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
+                                  rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
        }
        else {
                float rotation = -mtex->rot;
@@ -587,7 +587,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
                co[2] = 0.0f;
 
                hasrgb = externtex(mtex, co, &intensity,
-                         rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
+                                  rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool);
        }
 
        intensity += br->texture_sample_bias;
index cd10ef0fe2fe8fc7033f926774a82cbe9e0c1bee..bc813472d7ec6c7a8f79edd879541cd23675c92c 100644 (file)
@@ -3902,10 +3902,13 @@ static void *do_projectpaint_thread(void *ph_v)
                                                        sub_v2_v2v2(samplecos, projPixel->projCoSS, pos);
                                                }
                                                /* taking 3d copy to account for 3D mapping too. It gets concatenated during sampling */
-                                               else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D)
+                                               else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
                                                        copy_v3_v3(samplecos, projPixel->worldCoSS);
-                                               else
-                                                       copy_v3_v3(samplecos, projPixel->projCoSS);
+                                               }
+                                               else {
+                                                       copy_v2_v2(samplecos, projPixel->projCoSS);
+                                                       samplecos[2] = 0.0f;
+                                               }
                                        }
 
                                        if (falloff > 0.0f) {
index 21e83918d384f1de60e4e2bcf517207063a630e4..6c9dd490f5dcfd98b0c1eb7253e8fe192421df04 100644 (file)
@@ -973,7 +973,8 @@ static float tex_strength(SculptSession *ss, Brush *br,
                        avg += br->texture_sample_bias;
                }
                else {
-                       avg = BKE_brush_sample_tex_3D(scene, br, point_2d, rgba, ss->tex_pool);
+                       const float point_3d[3] = {point_2d[0], point_2d[1], 0.0f};
+                       avg = BKE_brush_sample_tex_3D(scene, br, point_3d, rgba, ss->tex_pool);
                }
        }
 
index 96f8753d99335c44b850453ade3d505f443f42de..26a0d0a2fa822fd01c7004bbd879973eb206d75f 100644 (file)
@@ -145,7 +145,7 @@ static void restrictbutton_recursive_ebone(bContext *C, EditBone *ebone_parent,
                                ebone->flag |= flag;
                        }
                        else {
-                                       ebone->flag &= ~flag;
+                               ebone->flag &= ~flag;
                        }
                }
        }
@@ -160,7 +160,7 @@ static void restrictbutton_recursive_bone(bContext *C, bArmature *arm, Bone *bon
                        bone->flag |= flag;
                }
                else {
-                               bone->flag &= ~flag;
+                       bone->flag &= ~flag;
                }
                restrictbutton_recursive_bone(C, arm, bone, flag, set_flag);
        }
index acd8a50f81c21a88ee8c77705119c82b51c82bcf..7a1b73584611f3aab18cdb0f9d23102b4777bd0a 100644 (file)
@@ -294,7 +294,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
 }
 
 /* only meant for timer usage */
-static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const const wmEvent *event)
+static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d = CTX_wm_region_view3d(C);
index 08f4206e4cabb65fe00eeed2adf23b66c3b491ba..f5eaa716dfa1adfbe6cbd255b4f0203dc23286bc 100644 (file)
@@ -1128,7 +1128,7 @@ static void shader_print_errors(const char *task, char *log, const char *code)
        fprintf(stderr, "%s\n", log);
 }
 
-static const char *gpu_shader_standard_defines()
+static const char *gpu_shader_standard_defines(void)
 {
        /* some useful defines to detect GPU type */
        if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY))