Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-05-08 15:21:02 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-05-08 15:22:14 +0300
commit49fe27ee46b4d9272957c21c13365db322ca8396 (patch)
tree235ed597431d68a62b3d7ac4f77c6599ccd09ba7 /source/blender/modifiers
parent53580265118236a096257b50f29d354243bdefe3 (diff)
Modifiers: sanitize/cleanup modifiers' copying & freeing code.
Should also fix T55000: Crash with hooks and curves in Cycles render.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c2
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c2
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c7
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c4
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c9
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c2
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c2
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c15
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c7
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c4
10 files changed, 22 insertions, 32 deletions
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index 0a15799f61a..f2698b43652 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -69,7 +69,7 @@ static void freeData(ModifierData *md)
{
CollisionModifierData *collmd = (CollisionModifierData *) md;
- if (collmd) {
+ if (collmd) { /* Seriously? */
if (collmd->bvhtree) {
BLI_bvhtree_free(collmd->bvhtree);
collmd->bvhtree = NULL;
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index c22901f1947..600dc3e28d1 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -66,7 +66,7 @@ static void freeData(ModifierData *md)
{
ExplodeModifierData *emd = (ExplodeModifierData *) md;
- if (emd->facepa) MEM_freeN(emd->facepa);
+ MEM_SAFE_FREE(emd->facepa);
}
static void copyData(ModifierData *md, ModifierData *target)
{
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index 37eabdf2425..823e67a7bc9 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -70,14 +70,17 @@ static void copyData(ModifierData *md, ModifierData *target)
FluidsimModifierData *fluidmd = (FluidsimModifierData *) md;
FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target;
- fluidsim_free(tfluidmd);
-
if (fluidmd->fss) {
tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
if (tfluidmd->fss && (tfluidmd->fss->meshVelocities != NULL)) {
tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities);
}
}
+
+ /* Seems to never be used, but for sqke of consistency... */
+ BLI_assert(fluidmd->point_cache == NULL);
+ BLI_assert(tfluidmd->point_cache == NULL);
+ tfluidmd->point_cache = NULL;
}
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 72c44121e0b..07d0b48fdb4 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -155,6 +155,10 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
}
MEM_SAFE_FREE(fluidmd->fss);
}
+
+ /* Seems to never be used, but for sqke of consistency... */
+ BLI_assert(fluidmd->point_cache == NULL);
+ fluidmd->point_cache = NULL;
return;
}
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 80c029157f7..80f07f579cd 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -67,13 +67,6 @@ static void copyData(ModifierData *md, ModifierData *target)
HookModifierData *hmd = (HookModifierData *) md;
HookModifierData *thmd = (HookModifierData *) target;
- if (thmd->curfalloff != NULL) {
- curvemapping_free(thmd->curfalloff);
- }
- if (thmd->indexar != NULL) {
- MEM_freeN(thmd->indexar);
- }
-
modifier_copyData_generic(md, target);
thmd->curfalloff = curvemapping_copy(hmd->curfalloff);
@@ -99,7 +92,7 @@ static void freeData(ModifierData *md)
curvemapping_free(hmd->curfalloff);
- if (hmd->indexar) MEM_freeN(hmd->indexar);
+ MEM_SAFE_FREE(hmd->indexar);
}
static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index a9c4afcc0af..240b6247cf5 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -167,8 +167,6 @@ static void copyData(ModifierData *md, ModifierData *target)
#endif
OceanModifierData *tomd = (OceanModifierData *) target;
- freeData(target);
-
modifier_copyData_generic(md, target);
tomd->refresh = 0;
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 8711384e1ee..288c684269e 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -82,9 +82,11 @@ static void freeData(ModifierData *md)
if (smd->mCache) {
ccgSubSurf_free(smd->mCache);
+ smd->mCache = NULL;
}
if (smd->emCache) {
ccgSubSurf_free(smd->emCache);
+ smd->emCache = NULL;
}
}
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index bed8f95fb87..353cea80d3f 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -63,20 +63,17 @@ static void freeData(ModifierData *md)
if (surmd) {
if (surmd->bvhtree) {
free_bvhtree_from_mesh(surmd->bvhtree);
- MEM_freeN(surmd->bvhtree);
+ MEM_SAFE_FREE(surmd->bvhtree);
}
- if (surmd->dm)
+ if (surmd->dm) {
surmd->dm->release(surmd->dm);
+ surmd->dm = NULL;
+ }
- if (surmd->x)
- MEM_freeN(surmd->x);
+ MEM_SAFE_FREE(surmd->x);
- if (surmd->v)
- MEM_freeN(surmd->v);
-
- surmd->bvhtree = NULL;
- surmd->dm = NULL;
+ MEM_SAFE_FREE(surmd->v);
}
}
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index e0c94d456c2..9abb9e3fe72 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -124,12 +124,11 @@ static void freeData(ModifierData *md)
MEM_SAFE_FREE(smd->verts[i].binds[j].vert_weights);
}
- MEM_freeN(smd->verts[i].binds);
+ MEM_SAFE_FREE(smd->verts[i].binds);
}
}
- MEM_freeN(smd->verts);
- smd->verts = NULL;
+ MEM_SAFE_FREE(smd->verts);
}
}
@@ -138,8 +137,6 @@ static void copyData(ModifierData *md, ModifierData *target)
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
SurfaceDeformModifierData *tsmd = (SurfaceDeformModifierData *)target;
- freeData(target);
-
modifier_copyData_generic(md, target);
if (smd->verts) {
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 00d7906a442..a22120d7b3d 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -66,10 +66,6 @@ static void copyData(ModifierData *md, ModifierData *target)
WarpModifierData *wmd = (WarpModifierData *) md;
WarpModifierData *twmd = (WarpModifierData *) target;
- if (twmd->curfalloff != NULL) {
- curvemapping_free(twmd->curfalloff);
- }
-
modifier_copyData_generic(md, target);
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);