replace BLI_strncpy with BLI_strncpy_utf8 where input isnt ensured to be valid.
also replace strcpy's which copy using "" with str[0]='\0'
This commit is contained in:
@@ -942,7 +942,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
|
||||
sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2);
|
||||
}
|
||||
else
|
||||
strcpy(buf, ""); /* empty string */
|
||||
buf[0]= '\0'; /* empty string */
|
||||
BLI_dynstr_append(path, buf);
|
||||
|
||||
/* need to add dot before property if there was anything precceding this */
|
||||
|
||||
@@ -418,7 +418,7 @@ void unlink_object(Object *ob)
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
ct->tar = NULL;
|
||||
strcpy(ct->subtarget, "");
|
||||
ct->subtarget[0]= '\0';
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
@@ -448,7 +448,7 @@ void unlink_object(Object *ob)
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
ct->tar = NULL;
|
||||
strcpy(ct->subtarget, "");
|
||||
ct->subtarget[0]= '\0';
|
||||
obt->recalc |= OB_RECALC_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9232,7 +9232,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
simasel->prv_w = 96;
|
||||
simasel->flag = 7; /* ??? elubie */
|
||||
strcpy (simasel->dir, U.textudir); /* TON */
|
||||
strcpy (simasel->file, "");
|
||||
simasel->file[0]= '\0';
|
||||
|
||||
simasel->returnfunc = NULL;
|
||||
simasel->title[0] = 0;
|
||||
@@ -9462,7 +9462,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
/* clear old targets to avoid problems */
|
||||
data->tar = NULL;
|
||||
strcpy(data->subtarget, "");
|
||||
data->subtarget[0]= '\0';
|
||||
}
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
|
||||
@@ -9492,7 +9492,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
/* clear old targets to avoid problems */
|
||||
data->tar = NULL;
|
||||
strcpy(data->subtarget, "");
|
||||
data->subtarget[0]= '\0';
|
||||
}
|
||||
}
|
||||
else if (con->type == CONSTRAINT_TYPE_LOCLIKE) {
|
||||
|
||||
@@ -1439,9 +1439,7 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op)
|
||||
pld->pose->flag &= ~POSE_DO_UNLOCK;
|
||||
|
||||
/* clear strings + search */
|
||||
strcpy(pld->headerstr, "");
|
||||
strcpy(pld->searchstr, "");
|
||||
strcpy(pld->searchold, "");
|
||||
pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0';
|
||||
pld->search_cursor= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -765,7 +765,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
|
||||
}
|
||||
else {
|
||||
/* pop up panel - no previous, or user didn't want search after previous */
|
||||
strcpy(name, "");
|
||||
name[0]= '\0';
|
||||
// XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) {
|
||||
// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound);
|
||||
// }
|
||||
|
||||
@@ -3371,10 +3371,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
|
||||
if(chainlen)
|
||||
sprintf(autoik, "AutoIK-Len: %d", chainlen);
|
||||
else
|
||||
strcpy(autoik, "");
|
||||
autoik[0]= '\0';
|
||||
}
|
||||
else
|
||||
strcpy(autoik, "");
|
||||
autoik[0]= '\0';
|
||||
|
||||
if (t->con.mode & CON_APPLY) {
|
||||
switch(t->num.idx_max) {
|
||||
|
||||
@@ -1666,13 +1666,13 @@ void calculatePropRatio(TransInfo *t)
|
||||
strcpy(t->proptext, "(Random)");
|
||||
break;
|
||||
default:
|
||||
strcpy(t->proptext, "");
|
||||
t->proptext[0]= '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i = 0 ; i < t->total; i++, td++) {
|
||||
td->factor = 1.0;
|
||||
}
|
||||
strcpy(t->proptext, "");
|
||||
t->proptext[0]= '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, ReportList *reports
|
||||
TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
|
||||
marker->flag= 1;
|
||||
marker->frame= 1;
|
||||
BLI_strncpy(marker->name, name, sizeof(marker->name));
|
||||
BLI_strncpy_utf8(marker->name, name, sizeof(marker->name));
|
||||
BLI_addtail(&act->markers, marker);
|
||||
return marker;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ static void rna_ksPath_RnaPath_get(PointerRNA *ptr, char *value)
|
||||
if (ksp->rna_path)
|
||||
strcpy(value, ksp->rna_path);
|
||||
else
|
||||
strcpy(value, "");
|
||||
value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_ksPath_RnaPath_length(PointerRNA *ptr)
|
||||
|
||||
@@ -253,7 +253,7 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value)
|
||||
char oldname[sizeof(ebone->name)], newname[sizeof(ebone->name)];
|
||||
|
||||
/* need to be on the stack */
|
||||
BLI_strncpy(newname, value, sizeof(ebone->name));
|
||||
BLI_strncpy_utf8(newname, value, sizeof(ebone->name));
|
||||
BLI_strncpy(oldname, ebone->name, sizeof(ebone->name));
|
||||
|
||||
ED_armature_bone_rename(arm, oldname, newname);
|
||||
@@ -266,7 +266,7 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value)
|
||||
char oldname[sizeof(bone->name)], newname[sizeof(bone->name)];
|
||||
|
||||
/* need to be on the stack */
|
||||
BLI_strncpy(newname, value, sizeof(bone->name));
|
||||
BLI_strncpy_utf8(newname, value, sizeof(bone->name));
|
||||
BLI_strncpy(oldname, bone->name, sizeof(bone->name));
|
||||
|
||||
ED_armature_bone_rename(arm, oldname, newname);
|
||||
|
||||
@@ -170,7 +170,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
|
||||
BLI_strncpy(oldname, con->name, sizeof(con->name));
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(con->name, value, sizeof(con->name));
|
||||
BLI_strncpy_utf8(con->name, value, sizeof(con->name));
|
||||
|
||||
/* make sure name is unique */
|
||||
if (ptr->id.data) {
|
||||
|
||||
@@ -215,7 +215,7 @@ static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
|
||||
if (dtar->rna_path)
|
||||
strcpy(value, dtar->rna_path);
|
||||
else
|
||||
strcpy(value, "");
|
||||
value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
|
||||
@@ -309,7 +309,7 @@ static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
|
||||
if (fcu->rna_path)
|
||||
strcpy(value, fcu->rna_path);
|
||||
else
|
||||
strcpy(value, "");
|
||||
value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
|
||||
|
||||
@@ -76,7 +76,7 @@ void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
|
||||
BLI_strncpy(oldname, kb->name, sizeof(kb->name));
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(kb->name, value, sizeof(kb->name));
|
||||
BLI_strncpy_utf8(kb->name, value, sizeof(kb->name));
|
||||
|
||||
/* make sure the name is truly unique */
|
||||
if (ptr->id.data) {
|
||||
|
||||
@@ -690,7 +690,7 @@ static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value
|
||||
Mesh *me= (Mesh*)ptr->id.data;
|
||||
CustomData *fdata= rna_mesh_fdata(me);
|
||||
CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
|
||||
BLI_strncpy(cdl->name, value, sizeof(cdl->name));
|
||||
BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
|
||||
CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
|
||||
}
|
||||
|
||||
@@ -802,7 +802,7 @@ static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value)
|
||||
Mesh *me= (Mesh*)ptr->id.data;
|
||||
CustomData *fdata= rna_mesh_fdata(me);
|
||||
CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
|
||||
BLI_strncpy(cdl->name, value, sizeof(cdl->name));
|
||||
BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name));
|
||||
CustomData_set_layer_unique_name(fdata, cdl - fdata->layers);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
|
||||
BLI_strncpy(oldname, md->name, sizeof(md->name));
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(md->name, value, sizeof(md->name));
|
||||
BLI_strncpy_utf8(md->name, value, sizeof(md->name));
|
||||
|
||||
/* make sure the name is truly unique */
|
||||
if (ptr->id.data) {
|
||||
|
||||
@@ -59,7 +59,7 @@ static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value)
|
||||
NlaStrip *data= (NlaStrip *)ptr->data;
|
||||
|
||||
/* copy the name first */
|
||||
BLI_strncpy(data->name, value, sizeof(data->name));
|
||||
BLI_strncpy_utf8(data->name, value, sizeof(data->name));
|
||||
|
||||
/* validate if there's enough info to do so */
|
||||
if (ptr->id.data) {
|
||||
|
||||
@@ -361,7 +361,7 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
|
||||
/* make a copy of the old name first */
|
||||
BLI_strncpy(oldname, node->name, sizeof(node->name));
|
||||
/* set new name */
|
||||
BLI_strncpy(node->name, value, sizeof(node->name));
|
||||
BLI_strncpy_utf8(node->name, value, sizeof(node->name));
|
||||
|
||||
nodeUniqueName(ntree, node);
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
Object *ob= (Object *)ptr->id.data;
|
||||
bDeformGroup *dg= (bDeformGroup *)ptr->data;
|
||||
BLI_strncpy(dg->name, value, sizeof(dg->name));
|
||||
BLI_strncpy_utf8(dg->name, value, sizeof(dg->name));
|
||||
defgroup_unique_name(dg, ob);
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
|
||||
dg= BLI_findlink(&ob->defbase, index-1);
|
||||
|
||||
if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name));
|
||||
else BLI_strncpy(value, "", sizeof(dg->name));
|
||||
else value[0]= '\0';
|
||||
}
|
||||
|
||||
int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
|
||||
@@ -535,7 +535,7 @@ void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result
|
||||
Object *ob= (Object*)ptr->id.data;
|
||||
bDeformGroup *dg= defgroup_find_name(ob, value);
|
||||
if(dg) {
|
||||
BLI_strncpy(result, value, maxlen);
|
||||
BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *resul
|
||||
}
|
||||
}
|
||||
|
||||
BLI_strncpy(result, "", maxlen);
|
||||
result[0]= '\0';
|
||||
}
|
||||
|
||||
void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen)
|
||||
@@ -585,7 +585,7 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res
|
||||
}
|
||||
}
|
||||
|
||||
BLI_strncpy(result, "", maxlen);
|
||||
result[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_Object_active_material_index_get(PointerRNA *ptr)
|
||||
@@ -836,7 +836,7 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str)
|
||||
if(ma)
|
||||
strcpy(str, ma->id.name+2);
|
||||
else
|
||||
strcpy(str, "");
|
||||
str[0]= '\0';
|
||||
}
|
||||
|
||||
static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
|
||||
@@ -222,7 +222,7 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
|
||||
char oldname[sizeof(pchan->name)], newname[sizeof(pchan->name)];
|
||||
|
||||
/* need to be on the stack */
|
||||
BLI_strncpy(newname, value, sizeof(pchan->name));
|
||||
BLI_strncpy_utf8(newname, value, sizeof(pchan->name));
|
||||
BLI_strncpy(oldname, pchan->name, sizeof(pchan->name));
|
||||
|
||||
ED_armature_bone_rename(ob->data, oldname, newname);
|
||||
@@ -411,7 +411,7 @@ static void rna_pose_bgroup_name_index_get(PointerRNA *ptr, char *value, int ind
|
||||
grp= BLI_findlink(&pose->agroups, index-1);
|
||||
|
||||
if(grp) BLI_strncpy(value, grp->name, sizeof(grp->name));
|
||||
else BLI_strncpy(value, "", sizeof(grp->name)); // XXX if invalid pointer, won't this crash?
|
||||
else value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_pose_bgroup_name_index_length(PointerRNA *ptr, int index)
|
||||
@@ -451,7 +451,7 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r
|
||||
}
|
||||
}
|
||||
|
||||
BLI_strncpy(result, "", maxlen);
|
||||
result[0]= '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ static void rna_GameProperty_type_set(PointerRNA *ptr, int value)
|
||||
static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
bProperty *prop= (bProperty*)(ptr->data);
|
||||
BLI_strncpy(prop->name, value, sizeof(prop->name));
|
||||
BLI_strncpy_utf8(prop->name, value, sizeof(prop->name));
|
||||
unique_property(NULL, prop, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -737,7 +737,7 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value)
|
||||
RenderEngineType *type= BLI_findlink(&R_engines, value);
|
||||
|
||||
if(type)
|
||||
BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine));
|
||||
BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine));
|
||||
}
|
||||
|
||||
static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
|
||||
@@ -810,7 +810,7 @@ static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value)
|
||||
Scene *scene= (Scene*)ptr->id.data;
|
||||
SceneRenderLayer *rl= (SceneRenderLayer*)ptr->data;
|
||||
|
||||
BLI_strncpy(rl->name, value, sizeof(rl->name));
|
||||
BLI_strncpy_utf8(rl->name, value, sizeof(rl->name));
|
||||
|
||||
if(scene->nodetree) {
|
||||
bNode *node;
|
||||
@@ -1011,7 +1011,7 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[])
|
||||
TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
|
||||
marker->flag= SELECT;
|
||||
marker->frame= 1;
|
||||
BLI_strncpy(marker->name, name, sizeof(marker->name));
|
||||
BLI_strncpy_utf8(marker->name, name, sizeof(marker->name));
|
||||
BLI_addtail(&scene->markers, marker);
|
||||
return marker;
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
|
||||
BLI_strncpy(oldname, seq->name+2, sizeof(seq->name)-2);
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(seq->name+2, value, sizeof(seq->name)-2);
|
||||
BLI_strncpy_utf8(seq->name+2, value, sizeof(seq->name)-2);
|
||||
|
||||
/* make sure the name is unique */
|
||||
seqbase_unique_name_recursive(&scene->ed->seqbase, seq);
|
||||
|
||||
@@ -53,7 +53,7 @@ static void rna_Text_filename_get(PointerRNA *ptr, char *value)
|
||||
if(text->name)
|
||||
strcpy(value, text->name);
|
||||
else
|
||||
strcpy(value, "");
|
||||
value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_Text_filename_length(PointerRNA *ptr)
|
||||
@@ -88,7 +88,7 @@ static void rna_TextLine_body_get(PointerRNA *ptr, char *value)
|
||||
if(line->line)
|
||||
strcpy(value, line->line);
|
||||
else
|
||||
strcpy(value, "");
|
||||
value[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_TextLine_body_length(PointerRNA *ptr)
|
||||
|
||||
@@ -260,7 +260,7 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str)
|
||||
if(mtex->tex)
|
||||
strcpy(str, mtex->tex->id.name+2);
|
||||
else
|
||||
strcpy(str, "");
|
||||
str[0]= '\0';
|
||||
}
|
||||
|
||||
static int rna_TextureSlot_output_node_get(PointerRNA *ptr)
|
||||
|
||||
@@ -560,7 +560,7 @@ static int set_engine(int argc, const char **argv, void *data)
|
||||
RenderData *rd = &scene->r;
|
||||
|
||||
if(BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) {
|
||||
BLI_strncpy(rd->engine, argv[1], sizeof(rd->engine));
|
||||
BLI_strncpy_utf8(rd->engine, argv[1], sizeof(rd->engine));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user