Fix T58819: Weight paint gradient crash
authorCampbell Barton <ideasman42@gmail.com>
Thu, 6 Dec 2018 00:19:18 +0000 (11:19 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 6 Dec 2018 00:22:00 +0000 (11:22 +1100)
source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c

index 21965bb30d8ebd610f601ed44513905d9deb3555..28f5c1304c8ea01ff9da3e16c5e01c4a18ffb528 100644 (file)
@@ -687,13 +687,15 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEven
 
        if (ret & OPERATOR_CANCELLED) {
                Object *ob = CTX_data_active_object(C);
-               Mesh *me = ob->data;
-               if (vert_cache->wpp.wpaint_prev) {
-                       BKE_defvert_array_free_elems(me->dvert, me->totvert);
-                       BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
-                       wpaint_prev_destroy(&vert_cache->wpp);
+               if (vert_cache != NULL) {
+                       Mesh *me = ob->data;
+                       if (vert_cache->wpp.wpaint_prev) {
+                               BKE_defvert_array_free_elems(me->dvert, me->totvert);
+                               BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
+                               wpaint_prev_destroy(&vert_cache->wpp);
+                       }
+                       MEM_freeN(vert_cache);
                }
-               MEM_freeN(vert_cache);
 
                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);