diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-12-17 21:54:34 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-12-17 21:54:34 +0300 |
commit | 5ad465c87f43f96e5c9a73c7cf1d52e13b47a5ed (patch) | |
tree | c6f40fdf32529b6adefb4f2f303771e2b89e25ea | |
parent | e998cb2c2e059c5db1d7bc97f68358b3f023bcef (diff) |
Fix T72430: GPencil normalize command crashes blender
When the stroke weights array was NULL, the function crash. Just check NULL value.
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 67ffc6adc9f..1331cc92d96 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1797,6 +1797,11 @@ static int gpencil_vertex_group_invert_exec(bContext *C, wmOperator *op) } CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { + /* Verify the strokes has something to change. */ + if ((gps->totpoints == 0) || (gps->dvert == NULL)) { + continue; + } + for (int i = 0; i < gps->totpoints; i++) { dvert = &gps->dvert[i]; MDeformWeight *dw = defvert_find_index(dvert, def_nr); @@ -1864,7 +1869,8 @@ static int gpencil_vertex_group_smooth_exec(bContext *C, wmOperator *op) MDeformVert *dverta, *dvertb; CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { - if (gps->dvert == NULL) { + /* Verify the strokes has something to change. */ + if ((gps->totpoints == 0) || (gps->dvert == NULL)) { continue; } @@ -1959,6 +1965,11 @@ static int gpencil_vertex_group_normalize_exec(bContext *C, wmOperator *op) } CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { + /* Verify the strokes has something to change. */ + if ((gps->totpoints == 0) || (gps->dvert == NULL)) { + continue; + } + /* look for max value */ float maxvalue = 0.0f; for (int i = 0; i < gps->totpoints; i++) { @@ -2027,10 +2038,11 @@ static int gpencil_vertex_group_normalize_all_exec(bContext *C, wmOperator *op) } CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { - /* verify the strokes has something to change */ - if (gps->totpoints == 0) { + /* Verify the strokes has something to change. */ + if ((gps->totpoints == 0) || (gps->dvert == NULL)) { continue; } + /* look for tot value */ float *tot_values = MEM_callocN(gps->totpoints * sizeof(float), __func__); |