diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-10 13:05:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-10 13:05:49 +0400 |
commit | 6e9e758d605741a2ecb8b0fbf24881a17dbe7453 (patch) | |
tree | f23e763320d7c199ab2bb1dcc8ec5c98daa14eb9 /source/blender | |
parent | bdc10e7b41cbb891e7a902c134591eb580c5766c (diff) |
fix for un-initialized memory use for modal inset/bevel.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 17 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 8 |
3 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 42036d1ea17..608df8dd9b3 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -103,7 +103,7 @@ enum { * returns 1 if successful, 0 otherwise (usually means there's no selection) * (if 0 is returns, *vec is unmodified) * */ -int calculateTransformCenter(struct bContext *C, int centerMode, float *cent3d, int *cent2d); +int calculateTransformCenter(struct bContext *C, int centerMode, float cent3d[3], int cent2d[2]); struct TransInfo; struct ScrArea; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 93ed7d37235..b6d89a62d05 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4498,13 +4498,18 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event) BevelData *opdata; float mlen[2]; - if (!edbm_bevel_init(C, op, TRUE)) + if (!edbm_bevel_init(C, op, TRUE)) { return OPERATOR_CANCELLED; + } - /* initialize mouse values */ opdata = op->customdata; - calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter); + /* initialize mouse values */ + if (!calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter)) { + /* in this case the tool will likely do nothing, + * ideally this will never happen and should be checked for above */ + opdata->mcenter[0] = opdata->mcenter[1] = 0; + } mlen[0] = opdata->mcenter[0] - event->mval[0]; mlen[1] = opdata->mcenter[1] - event->mval[1]; opdata->initial_length = len_v2(mlen); @@ -4795,8 +4800,12 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, wmEvent *event) opdata = op->customdata; - calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter); /* initialize mouse values */ + if (!calculateTransformCenter(C, V3D_CENTROID, NULL, opdata->mcenter)) { + /* in this case the tool will likely do nothing, + * ideally this will never happen and should be checked for above */ + opdata->mcenter[0] = opdata->mcenter[1] = 0; + } mlen[0] = opdata->mcenter[0] - event->mval[0]; mlen[1] = opdata->mcenter[1] - event->mval[1]; opdata->initial_length = len_v2(mlen); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b437d186549..ea86083fac4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1178,10 +1178,10 @@ int transformEvent(TransInfo *t, wmEvent *event) return OPERATOR_PASS_THROUGH; } -int calculateTransformCenter(bContext *C, int centerMode, float *cent3d, int *cent2d) +int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int cent2d[2]) { TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data"); - int success = 1; + int success; t->state = TRANS_RUNNING; @@ -1196,10 +1196,10 @@ int calculateTransformCenter(bContext *C, int centerMode, float *cent3d, int *ce t->around = centerMode; // override userdefined mode if (t->total == 0) { - success = 0; + success = FALSE; } else { - success = 1; + success = TRUE; calculateCenter(t); |