code cleanup: replace strcpy with BLI_strncpy for fixed size strings, and correct...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 4 Aug 2013 18:12:49 +0000 (18:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 4 Aug 2013 18:12:49 +0000 (18:12 +0000)
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/sketch.c
source/blender/bmesh/operators/bmo_wireframe.c
source/blender/editors/interface/resources.c
source/blender/imbuf/intern/colormanagement.c
source/blender/modifiers/intern/MOD_skin.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp

index b8d851d082ac15b077b74de576a38c44f343223a..ef1235c2b64f799a72194ed0c0b35c28b2e2a1f5 100644 (file)
@@ -2080,6 +2080,8 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
                        axis = data->type - 20;
                }
                
+               BLI_assert((unsigned int)axis < 3);
+
                /* Target defines the animation */
                s = (vec[axis] - data->min) / (data->max - data->min);
                CLAMP(s, 0, 1);
index 707d97a1cf1405d2fa986706359fa7500a3ed5a1..bbd637a0a77ac63bee57eb9d53b823534c6a337e 100644 (file)
@@ -487,7 +487,7 @@ void sk_endContinuousStroke(SK_Stroke *stk)
 void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk)
 {
        if (stk) {
-               memcpy(&sketch->next_point, stk->points[stk->nb_points - 1].p, sizeof(SK_Point));
+               memcpy(&(sketch->next_point), &(stk->points[stk->nb_points - 1]), sizeof(SK_Point));
        }
 }
 
index cb2dc4b89f6d0394dc146b1fef59277c8c288bea..c07e2c3bbf2d6ff793924c57a650e4a0735306c6 100644 (file)
@@ -177,7 +177,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
 
        /* will over-alloc, but makes for easy lookups by index to keep aligned  */
        BMVert **verts_boundary = use_boundary ?
-                                 MEM_mallocN(sizeof(BMVert **) * totvert_orig, __func__) : NULL;
+                                 MEM_mallocN(sizeof(BMVert *) * totvert_orig, __func__) : NULL;
 
        float  *verts_relfac    = use_relative_offset ?
                                  MEM_mallocN(sizeof(float) * totvert_orig, __func__) : NULL;
index dc780d6a4f14821724b5434e9526ba278bec3055..1ef4d43c9f3aa2fc6f57858f7e401603aaba8322 100644 (file)
@@ -1953,7 +1953,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
                bTheme *btheme;
                for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-                       if (btheme->tseq.movieclip[0] == 0) {
+                       if (btheme->tseq.movieclip[3] == 0) {
                                rgba_char_args_set(btheme->tseq.movieclip,  32, 32, 143, 255);
                        }
                }
@@ -2002,7 +2002,7 @@ void init_userdef_do_versions(void)
        if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
                bTheme *btheme;
                for (btheme = U.themes.first; btheme; btheme = btheme->next) {
-                       if (btheme->tseq.movieclip[0] == 0) {
+                       if (btheme->tseq.mask[3] == 0) {
                                rgba_char_args_set(btheme->tseq.mask,  152, 78, 62, 255);
                        }
                }
index 238e68b141c0a9689dc0cb7e33142143733151f3..0167eaccef0c3c21a4e137e943b5e403df2fd212 100644 (file)
@@ -2787,9 +2787,9 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s
            check_glsl_display_processor_changed(view_settings, display_settings, from_colorspace))
        {
                /* Store settings of processor for further comparison. */
-               strcpy(global_glsl_state.view, view_settings->view_transform);
-               strcpy(global_glsl_state.display, display_settings->display_device);
-               strcpy(global_glsl_state.input, from_colorspace);
+               BLI_strncpy(global_glsl_state.view, view_settings->view_transform, MAX_COLORSPACE_NAME);
+               BLI_strncpy(global_glsl_state.display, display_settings->display_device, MAX_COLORSPACE_NAME);
+               BLI_strncpy(global_glsl_state.input, from_colorspace, MAX_COLORSPACE_NAME);
                global_glsl_state.exposure = view_settings->exposure;
                global_glsl_state.gamma = view_settings->gamma;
 
index df0a0266154fa51826cb54b9a580e17a95b3ccdf..56571f69e0975ca2a6e1dc111a78d0f5a1e7f125 100644 (file)
@@ -411,7 +411,7 @@ static Frame **collect_hull_frames(int v, SkinNode *frames,
        int nbr, i;
 
        (*tothullframe) = emap[v].count;
-       hull_frames = MEM_callocN(sizeof(Frame * *) * (*tothullframe),
+       hull_frames = MEM_callocN(sizeof(Frame *) * (*tothullframe),
                                  "hull_from_frames.hull_frames");
        i = 0;
        for (nbr = 0; nbr < emap[v].count; nbr++) {
index 5703527eae0c0040408f1256378aeefbf1a5a01f..7b5f5a7096a9db3748d4895be5aea687b6bd7391 100644 (file)
@@ -379,7 +379,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
                        // to the original file working directory
 
                        if (exitstring != "")
-                               strcpy(basedpath, exitstring.Ptr());
+                               BLI_strncpy(basedpath, exitstring.ReadPtr(), sizeof(basedpath));
 
                        // load relative to the last loaded file, this used to be relative
                        // to the first file but that makes no sense, relative paths in