[Bf-blender-cvs] [29e5f37bdd8] soc-2017-normal-tools: Fix memleak in Weighted Normals modifier when autosmooth is disabled.

Bastien Montagne noreply at git.blender.org
Mon Aug 7 10:32:14 CEST 2017


Commit: 29e5f37bdd86a106233dff859ff0ed7fa293a412
Author: Bastien Montagne
Date:   Mon Aug 7 10:31:19 2017 +0200
Branches: soc-2017-normal-tools
https://developer.blender.org/rB29e5f37bdd86a106233dff859ff0ed7fa293a412

Fix memleak in Weighted Normals modifier when autosmooth is disabled.

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

M	source/blender/modifiers/intern/MOD_weighted_normal.c

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

diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 2dd5aa075da..9933e692acd 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -480,6 +480,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
 	WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
 
 	Mesh *me = ob->data;
+
+	if (!(me->flag & ME_AUTOSMOOTH)) {
+		modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
+		return dm;
+	}
+
 	int numPoly = dm->getNumPolys(dm);
 	int numVerts = dm->getNumVerts(dm);
 	int numEdges = dm->getNumEdges(dm);
@@ -505,11 +511,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
 
 	short(*clnors)[2];
 
-	if (!(me->flag & ME_AUTOSMOOTH)) {
-		modifier_setError((ModifierData *)wnmd, "Enable 'Auto Smooth' option in mesh settings");
-		return dm;
-	}
-
 	clnors = CustomData_duplicate_referenced_layer(&dm->loopData, CD_CUSTOMLOOPNORMAL, numLoops);
 	if (!clnors) {
 		DM_add_loop_layer(dm, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL);
@@ -532,6 +533,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
 				numLoops, mpoly, numPoly, polynors, dvert, defgrp_index, use_invert_vgroup, weight);
 			break;
 	}
+
 	if (free_polynors) {
 		MEM_freeN(polynors);
 	}




More information about the Bf-blender-cvs mailing list