diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index e935573cf67..b1492fce9d4 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1094,8 +1094,14 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) left_len= splitIDname(name, left, &nr); /* if new name will be too long, truncate it */ - if(nr>999 && strlen(left)>16) left[16]= 0; - else if(strlen(left)>17) left[17]= 0; + if(nr > 999 && left_len > 16) { + left[16]= 0; + left_len= 16; + } + else if(left_len > 17) { + left[17]= 0; + left_len= 17; + } for(idtest= lb->first; idtest; idtest= idtest->next) { if( (id != idtest) && @@ -1136,10 +1142,11 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* otherwise just continue and use a number suffix */ } - if(nr > 999 && strlen(left) > 16) { + if(nr > 999 && left_len > 16) { /* this would overflow name buffer */ left[16] = 0; - strcpy( name, left ); + /* left_len = 16; */ /* for now this isnt used again */ + memcpy(name, left, sizeof(char) * 16); continue; } /* this format specifier is from hell... */