[Bf-blender-cvs] [5ad465c87f4] master: Fix T72430: GPencil normalize command crashes blender

Antonio Vazquez noreply at git.blender.org
Tue Dec 17 19:55:23 CET 2019


Commit: 5ad465c87f43f96e5c9a73c7cf1d52e13b47a5ed
Author: Antonio Vazquez
Date:   Tue Dec 17 19:54:34 2019 +0100
Branches: master
https://developer.blender.org/rB5ad465c87f43f96e5c9a73c7cf1d52e13b47a5ed

Fix T72430: GPencil normalize command crashes blender

When the stroke weights array was NULL, the function crash. Just check NULL value.

===================================================================

M	source/blender/editors/gpencil/gpencil_data.c

===================================================================

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__);



More information about the Bf-blender-cvs mailing list