Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-26 22:51:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-26 22:51:10 +0400
commit58587a38818b0dba25886c97d584285fef4e9249 (patch)
tree38e00681d39ee6a0f588232c9ef70ec5f80e22df /source/blender/editors
parente897c8e83e1277767d9a44cb0ecb6f8a279dddc3 (diff)
replace strncpy with BLI_strncpy, in some cases strncpy was being misused since it doesnt ensure \0 termination.
also dont call CTX_data_scene() twice when checking for function arguments.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/poselib.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c8
-rw-r--r--source/blender/editors/space_text/text_draw.c3
-rw-r--r--source/blender/editors/util/editmode_undo.c2
6 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 8a7d837d2a8..bf2e17c4e87 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -993,7 +993,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
}
else {
- strncpy(tempstr, pld->searchstr, 64);
+ BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
}
/* get marker name */
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 74e91cf32ea..019d6df9b73 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3918,7 +3918,7 @@ void PE_undo_push(Scene *scene, const char *str)
/* make new */
edit->curundo= undo= MEM_callocN(sizeof(PTCacheUndo), "particle undo file");
- strncpy(undo->name, str, 64-1);
+ BLI_strncpy(undo->name, str, sizeof(undo->name));
BLI_addtail(&edit->undo, undo);
/* and limit amount to the maximum */
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index ba0c2c8be92..345cda63f5a 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -34,6 +34,7 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "DNA_userdef_types.h"
@@ -106,7 +107,7 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor
BLI_addtail(&stack->elems, uel);
/* name can be a dynamic string */
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
/* limit amount to the maximum amount*/
nr= 0;
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index a6cc65017bb..c0919ef3043 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -169,11 +169,11 @@ static void UNUSED_FUNCTION(select_single_seq)(Scene *scene, Sequence *seq, int
if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) {
if(seq->strip)
- strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
else if(seq->type==SEQ_SOUND) {
if(seq->strip)
- strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
seq->flag|= SELECT;
recurs_sel_seq(seq);
@@ -389,12 +389,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) {
if(seq->strip) {
- strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
} else
if (seq->type == SEQ_SOUND) {
if(seq->strip) {
- strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 4c617115a3d..10d355bd0c3 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1421,8 +1421,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
y -= st->lheight;
- strncpy(str, item->name, SUGG_LIST_WIDTH);
- str[SUGG_LIST_WIDTH] = '\0';
+ BLI_strncpy(str, item->name, SUGG_LIST_WIDTH);
w = text_font_width(st, str);
diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c
index bcbc134d06d..f38ae136f71 100644
--- a/source/blender/editors/util/editmode_undo.c
+++ b/source/blender/editors/util/editmode_undo.c
@@ -142,7 +142,7 @@ void undo_editmode_push(bContext *C, const char *name,
/* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo editmode");
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
BLI_addtail(&undobase, uel);
uel->getdata= getdata;