minor changes for confusing code.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jul 2013 04:45:40 +0000 (04:45 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jul 2013 04:45:40 +0000 (04:45 +0000)
- memset() was argument was truncated.
- outliner had redundant NULL check.
- node texture was allocating memory to make a unique name which isnt needed for a fixed size string.

source/blender/editors/render/render_preview.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/nodes/texture/nodes/node_texture_output.c

index 8da66c114d5e4b7b99505f82ef565dd7aaa91dbe..4bd8a7d426a87476e8a99ac549208c93bd24bbb6 100644 (file)
@@ -964,7 +964,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
 
                br->icon_imbuf = get_brush_icon(br);
 
-               memset(sp->pr_rect, 0x888888, sp->sizex * sp->sizey * sizeof(unsigned int));
+               memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
 
                if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
                        return;
index eb33d799dff1dade2a104cf4487207f3ad23abfc..cf99254e8bb749b1b911e4a1632ebf00926b6021 100644 (file)
@@ -1131,7 +1131,7 @@ static int need_add_seq_dup(Sequence *seq)
 {
        Sequence *p;
 
-       if ((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name))
+       if ((!seq->strip) || (!seq->strip->stripdata))
                return(1);
 
        /*
index 235cb560a99a45aae89aa502699e0accbd5cd4f4..37e527f611aca98fb17ac329e093a68beda5496b 100644 (file)
@@ -80,12 +80,13 @@ static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *exe
 static void unique_name(bNode *node)
 {
        TexNodeOutput *tno = (TexNodeOutput *)node->storage;
-       char *new_name = NULL;
+       char new_name[sizeof(tno->name)];
        int new_len = 0;
        int suffix;
        bNode *i;
        char *name = tno->name;
        
+       new_name[0] = '\0';
        i = node;
        while (i->prev) i = i->prev;
        for (; i; i = i->next) {
@@ -96,7 +97,7 @@ static void unique_name(bNode *node)
                        continue;
                }
 
-               if (!new_name) {
+               if (new_name[0] == '\0') {
                        int len = strlen(name);
                        if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) {
                                new_len = len;
@@ -107,17 +108,15 @@ static void unique_name(bNode *node)
                                if (new_len > (sizeof(tno->name) - 1))
                                        new_len = (sizeof(tno->name) - 1);
                        }
-                       
-                       new_name = MEM_mallocN(new_len + 1, "new_name");
-                       strcpy(new_name, name);
+
+                       BLI_strncpy(new_name, name, sizeof(tno->name));
                        name = new_name;
                }
                sprintf(new_name + new_len - 4, ".%03d", ++suffix);
        }
        
-       if (new_name) {
-               strcpy(tno->name, new_name);
-               MEM_freeN(new_name);
+       if (new_name[0] != '\0') {
+               BLI_strncpy(tno->name, new_name, sizeof(tno->name));
        }
 }