Commit: 42fde5d32b35bef65f292461d800ebc36f35396f
Author: Sergey Sharybin
Date:   Tue Jun 26 11:31:28 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB42fde5d32b35bef65f292461d800ebc36f35396f

Fix memory leak when duplicating particles

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

M       source/blender/blenkernel/intern/object_dupli.c

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

diff --git a/source/blender/blenkernel/intern/object_dupli.c 
b/source/blender/blenkernel/intern/object_dupli.c
index b7748039f62..33b65dbe4a3 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -837,7 +837,6 @@ static void make_duplis_particle_system(const DupliContext 
*ctx, ParticleSystem
        float (*obmat)[4];
        int a, b, hair = 0;
        int totpart, totchild, totcollection = 0 /*, pa_num */;
-       RNG *rng;
 
        int no_draw_flag = PARS_UNEXIST;
 
@@ -859,8 +858,6 @@ static void make_duplis_particle_system(const DupliContext 
*ctx, ParticleSystem
        totpart = psys->totpart;
        totchild = psys->totchild;
 
-       rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed);
-
        if ((for_render || part->draw_as == PART_DRAW_REND) && 
ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
                ParticleSimulationData sim = {NULL};
                sim.depsgraph = ctx->depsgraph;
@@ -901,6 +898,7 @@ static void make_duplis_particle_system(const DupliContext 
*ctx, ParticleSystem
                        totpart = psys->totcached;
                }
 
+               RNG *rng = BLI_rng_new_srandom(31415926u + (unsigned 
int)psys->seed);
                psys_check_group_weights(part);
 
                psys->lattice_deform_data = 
psys_create_lattice_deform_data(&sim);
@@ -1121,6 +1119,8 @@ static void make_duplis_particle_system(const 
DupliContext *ctx, ParticleSystem
                }
                else
                        *ob = obcopy;
+
+               BLI_rng_free(rng);
        }
 
        /* clean up */
@@ -1133,8 +1133,6 @@ static void make_duplis_particle_system(const 
DupliContext *ctx, ParticleSystem
                end_latt_deform(psys->lattice_deform_data);
                psys->lattice_deform_data = NULL;
        }
-
-       BLI_rng_free(rng);
 }
 
 static void make_duplis_particles(const DupliContext *ctx)

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

Reply via email to