Commit: 03ef9f32148acb45c4940cf93d7d8afb850231d0
Author: Sybren A. Stüvel
Date:   Thu Jul 5 12:21:33 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB03ef9f32148acb45c4940cf93d7d8afb850231d0

Fluidsim: fixed memory leak

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

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

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

diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c 
b/source/blender/modifiers/intern/MOD_fluidsim.c
index bb87d0065fe..ebea7250d18 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -69,11 +69,20 @@ static void copyData(const ModifierData *md, ModifierData 
*target, const int UNU
        const FluidsimModifierData *fluidmd = (const FluidsimModifierData *) md;
        FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target;
 
-       if (fluidmd->fss) {
-               tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
-               if (tfluidmd->fss && (tfluidmd->fss->meshVelocities != NULL)) {
-                       tfluidmd->fss->meshVelocities = 
MEM_dupallocN(tfluidmd->fss->meshVelocities);
-               }
+       /* Free any FSS that was allocated in initData() */
+       if (tfluidmd->fss) {
+               MEM_SAFE_FREE(tfluidmd->fss->meshVelocities);
+               MEM_freeN(tfluidmd->fss);
+       }
+
+       if (fluidmd->fss == NULL) {
+               tfluidmd->fss = NULL;
+               return;
+       }
+
+       tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
+       if (tfluidmd->fss->meshVelocities != NULL) {
+               tfluidmd->fss->meshVelocities = 
MEM_dupallocN(tfluidmd->fss->meshVelocities);
        }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to