replace strncpy with BLI_strncpy for cases we expect the string to be NULL terminated.

This commit is contained in:
Campbell Barton 2013-07-14 22:08:56 +00:00
parent 1c2ff55334
commit 9c8516703d
5 changed files with 12 additions and 9 deletions

@ -32,6 +32,7 @@
#include "DNA_movieclip_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
extern "C" {
#include "BLI_voronoi.h"
@ -76,7 +77,7 @@ public:
void deinitializeTileData(rcti *rect, void *data);
void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));}
void setTrackingObject(const char *object) { BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject)); }
void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
void executePixel(float output[4], int x, int y, void *data);

@ -33,6 +33,7 @@
#include "DNA_tracking_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
/**
* Class with implementation of green screen gradient rasterization
@ -60,8 +61,8 @@ public:
TrackPositionOperation();
void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
void setTrackingObject(char *object) {strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));}
void setTrackName(char *track) {strncpy(this->m_trackName, track, sizeof(this->m_trackName));}
void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); }
void setTrackName(char *track) { BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName)); }
void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
void setAxis(int value) {this->m_axis = value;}
void setPosition(int value) {this->m_position = value;}

@ -50,6 +50,7 @@
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_threads.h"
#include "BLI_string.h"
#include "BLF_translation.h"
@ -250,13 +251,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
clip = ED_space_clip_get_clip(sc);
if (clip) {
strncpy(path, clip->name, sizeof(path));
BLI_strncpy(path, clip->name, sizeof(path));
BLI_path_abs(path, G.main->name);
BLI_parent_dir(path);
}
else {
strncpy(path, U.textudir, sizeof(path));
BLI_strncpy(path, U.textudir, sizeof(path));
}
if (RNA_struct_property_is_set(op->ptr, "files"))

@ -761,7 +761,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
BKE_sequencer_sort(scene);
/* last active name */
strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR - 1);
BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir));
if (RNA_boolean_get(op->ptr, "overlap") == FALSE) {
if (BKE_sequence_test_overlap(ed->seqbasep, seq))

@ -115,7 +115,7 @@ static TransformOrientation *createViewSpace(bContext *C, ReportList *UNUSED(rep
View3D *v3d = CTX_wm_view3d(C);
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
/* If an object is used as camera, then this space is the same as object space! */
strncpy(name, v3d->camera->id.name + 2, MAX_NAME);
BLI_strncpy(name, v3d->camera->id.name + 2, MAX_NAME);
}
else {
strcpy(name, "Custom View");
@ -141,7 +141,7 @@ static TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(r
/* use object name if no name is given */
if (name[0] == 0) {
strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
BLI_strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
}
return addMatrixSpace(C, mat, name, overwrite);
@ -306,7 +306,7 @@ TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], char name[],
if (ts == NULL) {
ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix");
BLI_addtail(transform_spaces, ts);
strncpy(ts->name, name, sizeof(ts->name));
BLI_strncpy(ts->name, name, sizeof(ts->name));
}
/* copy matrix into transform space */