diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-19 13:21:14 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-19 13:21:14 +0300 |
commit | e9aaf5ed211d5f71fd2934c8814143c15fd47d5e (patch) | |
tree | 1e56f806d2ad8342f8614ce5509bfb5b444c8033 /source/blender/modifiers/intern/MOD_fluidsim.c | |
parent | 72c9141a7a56fa4762ac0daae501f1609532506c (diff) |
Fix (unreported) memory leak in Fluid modifier copying.
Also generally simplify/sanitize this copy code.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluidsim.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_fluidsim.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index c202c5e1cb4..1964e940cb2 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -68,12 +68,13 @@ static void copyData(ModifierData *md, ModifierData *target) FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target; - if (tfluidmd->fss) - MEM_freeN(tfluidmd->fss); - - tfluidmd->fss = MEM_dupallocN(fluidmd->fss); - if (tfluidmd->fss && (tfluidmd->fss->meshVelocities != NULL)) { - tfluidmd->fss->meshVelocities = MEM_dupallocN(tfluidmd->fss->meshVelocities); + 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); + } } } |