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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-12 10:53:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-12 10:53:47 +0400
commitaedd4af57e5777dd32585560980f4661ec4d491d (patch)
tree81d7514200d498b01ef621c83052cf5f42aac84f /source
parent0873cbaed5aea31f3fc8b16dacecb2d332c9b6f5 (diff)
code cleanup/bugfix uninitialized values
- edgebisect bmesh operator used uninialized beauty field. - BLI_join_dirfile could read from before the string bounds when passed an empty dir string. - pransform could use an uninitialized projected coordinate (unlikely but possible) - RNA_property_path_from_ID_check would compare against an uninitialized pointer when the path wasn't found. also have bmesh walker use BM_edge_other_vert() utility function.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/intern/path_util.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c11
-rw-r--r--source/blender/bmesh/operators/bmo_subdivide.c4
-rw-r--r--source/blender/editors/transform/transform.c63
-rw-r--r--source/blender/editors/transform/transform.h6
-rw-r--r--source/blender/makesrna/intern/rna_access.c8
6 files changed, 52 insertions, 46 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 0d251133e0d..dccec7a6a42 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -1523,9 +1523,9 @@ void BLI_join_dirfile(char *dst, const size_t maxlen, const char *dir, const cha
}
/* inline BLI_add_slash */
- if (dst[dirlen - 1] != SEP) {
- dst[dirlen++]= SEP;
- dst[dirlen ]= '\0';
+ if ((dirlen > 0) && (dst[dirlen - 1] != SEP)) {
+ dst[dirlen++] = SEP;
+ dst[dirlen ] = '\0';
}
if (dirlen >= maxlen) {
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index cd815c9be83..23d82f0ab34 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -256,8 +256,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
owalk = *iwalk;
- if (iwalk->lastv == e->v1) v = e->v2;
- else v = e->v1;
+ v = BM_edge_other_vert(e, iwalk->lastv);
if (!BM_vert_is_manifold(walker->bm, v)) {
BMW_reset(walker);
@@ -411,10 +410,7 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
lwalk = BMW_state_add(walker);
*lwalk = owalk;
- if (lwalk->lastv == owalk.cur->v1) lwalk->lastv = owalk.cur->v2;
- else lwalk->lastv = owalk.cur->v1;
-
- lwalk->startv = lwalk->lastv;
+ lwalk->lastv = lwalk->startv = BM_edge_other_vert(owalk.cur, lwalk->lastv);
BLI_ghash_free(walker->visithash, NULL, NULL);
walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 2");
@@ -625,8 +621,9 @@ static void *bmw_FaceLoopWalker_step(BMWalker *walker)
l = l->radial_next;
- if (lwalk->nocalc)
+ if (lwalk->nocalc) {
return f;
+ }
if (!bmw_FaceLoopWalker_include_face(walker, l)) {
l = lwalk->l;
diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c
index 9a6d9e7b836..24f9c1e9937 100644
--- a/source/blender/bmesh/operators/bmo_subdivide.c
+++ b/source/blender/bmesh/operators/bmo_subdivide.c
@@ -1080,10 +1080,10 @@ void bmo_edgebisect_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
BMEdge *e;
- SubDParams params;
+ SubDParams params = {0};
int skey;
- params.numcuts = BMO_slot_get(op, "numcuts")->data.i;
+ params.numcuts = BMO_slot_int_get(op, "numcuts");
params.op = op;
BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 7b98a2f0083..4334d323737 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -136,28 +136,28 @@ static void convertViewVec2D(View2D *v2d, float vec[3], int dx, int dy)
vec[2]= 0.0f;
}
-void convertViewVec(TransInfo *t, float vec[3], int dx, int dy)
+void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy)
{
if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) {
float mval_f[2];
mval_f[0] = dx;
mval_f[1] = dy;
- ED_view3d_win_to_delta(t->ar, mval_f, vec);
+ ED_view3d_win_to_delta(t->ar, mval_f, r_vec);
}
else if(t->spacetype==SPACE_IMAGE) {
float aspx, aspy;
- convertViewVec2D(t->view, vec, dx, dy);
+ convertViewVec2D(t->view, r_vec, dx, dy);
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
- vec[0]*= aspx;
- vec[1]*= aspy;
+ r_vec[0] *= aspx;
+ r_vec[1] *= aspy;
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
- convertViewVec2D(t->view, vec, dx, dy);
+ convertViewVec2D(t->view, r_vec, dx, dy);
}
else if(ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) {
- convertViewVec2D(&t->ar->v2d, vec, dx, dy);
+ convertViewVec2D(&t->ar->v2d, r_vec, dx, dy);
}
else if(t->spacetype==SPACE_CLIP) {
View2D *v2d = t->view;
@@ -166,17 +166,17 @@ void convertViewVec(TransInfo *t, float vec[3], int dx, int dy)
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
- vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
- vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
- vec[2]= 0.0f;
+ r_vec[0] = (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
+ r_vec[1] = (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
+ r_vec[2] = 0.0f;
}
else {
printf("%s: called in an invalid context\n", __func__);
- zero_v3(vec);
+ zero_v3(r_vec);
}
}
-void projectIntView(TransInfo *t, float *vec, int *adr)
+void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype==SPACE_VIEW3D) {
if(t->ar->regiontype == RGN_TYPE_WINDOW)
@@ -229,26 +229,31 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
}
}
-void projectFloatView(TransInfo *t, float *vec, float *adr)
+void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
{
- if (t->spacetype==SPACE_VIEW3D) {
- if(t->ar->regiontype == RGN_TYPE_WINDOW)
- project_float_noclip(t->ar, vec, adr);
- }
- else if(ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
- int a[2];
-
- projectIntView(t, vec, a);
- adr[0]= a[0];
- adr[1]= a[1];
+ switch (t->spacetype) {
+ case SPACE_VIEW3D:
+ {
+ if (t->ar->regiontype == RGN_TYPE_WINDOW) {
+ project_float_noclip(t->ar, vec, adr);
+ return;
+ }
+ break;
+ }
+ case SPACE_IMAGE:
+ case SPACE_CLIP:
+ case SPACE_IPO:
+ case SPACE_NLA:
+ {
+ int a[2];
+ projectIntView(t, vec, a);
+ adr[0] = a[0];
+ adr[1] = a[1];
+ return;
+ }
}
- else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
- int a[2];
- projectIntView(t, vec, a);
- adr[0]= a[0];
- adr[1]= a[1];
- }
+ zero_v2(adr);
}
void applyAspectRatio(TransInfo *t, float *vec)
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 48c05f00ea8..0bef33149d7 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -444,9 +444,9 @@ void transformApply(struct bContext *C, TransInfo *t);
int transformEnd(struct bContext *C, TransInfo *t);
void setTransformViewMatrices(TransInfo *t);
-void convertViewVec(TransInfo *t, float *vec, int dx, int dy);
-void projectIntView(TransInfo *t, float *vec, int *adr);
-void projectFloatView(TransInfo *t, float *vec, float *adr);
+void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy);
+void projectIntView(TransInfo *t, const float vec[3], int adr[2]);
+void projectFloatView(TransInfo *t, const float vec[3], float adr[2]);
void applyAspectRatio(TransInfo *t, float *vec);
void removeAspectRatio(TransInfo *t, float *vec);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 2ccd7d293d3..543824eb5d5 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1430,8 +1430,12 @@ int RNA_property_path_from_ID_check(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA *r_prop;
RNA_id_pointer_create(ptr->id.data, &id_ptr);
- RNA_path_resolve(&id_ptr, path, &r_ptr, &r_prop);
- ret = (prop == r_prop);
+ if (RNA_path_resolve(&id_ptr, path, &r_ptr, &r_prop) == TRUE) {
+ ret = (prop == r_prop);
+ }
+ else {
+ ret = FALSE;
+ }
MEM_freeN(path);
}