[Bf-blender-cvs] [a5d394fad23] master: Fix segfault when trying to free uninitialized loop normals

Sebastian Parborg noreply at git.blender.org
Fri May 15 13:39:41 CEST 2020


Commit: a5d394fad23280687880aee0082797cf8dd1cdd5
Author: Sebastian Parborg
Date:   Fri May 15 13:37:04 2020 +0200
Branches: master
https://developer.blender.org/rBa5d394fad23280687880aee0082797cf8dd1cdd5

Fix segfault when trying to free uninitialized loop normals

Forgot this corner case when I created the new normal flip code.

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

M	source/blender/editors/mesh/editmesh_tools.c

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

diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index bfd88de4c66..684bb73dc0e 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2104,7 +2104,10 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op)
     if (flip_custom_normals(em->bm, lnors_ed_arr) || has_flipped_faces) {
       EDBM_update_generic(obedit->data, true, false);
     }
-    BM_loop_normal_editdata_array_free(lnors_ed_arr);
+
+    if (lnors_ed_arr != NULL) {
+      BM_loop_normal_editdata_array_free(lnors_ed_arr);
+    }
   }
 
   MEM_freeN(objects);
@@ -2419,7 +2422,9 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
     if (inside) {
       EDBM_op_callf(em, op, "reverse_faces faces=%hf flip_multires=%b", BM_ELEM_SELECT, true);
       flip_custom_normals(em->bm, lnors_ed_arr);
-      BM_loop_normal_editdata_array_free(lnors_ed_arr);
+      if (lnors_ed_arr != NULL) {
+        BM_loop_normal_editdata_array_free(lnors_ed_arr);
+      }
     }
 
     EDBM_update_generic(obedit->data, true, false);



More information about the Bf-blender-cvs mailing list