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:
authorLukas Tönne <lukas.toenne@gmail.com>2015-01-08 14:40:27 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-01-20 11:30:09 +0300
commitb292d783f28958a54f608375e6e99a92be5522d6 (patch)
tree0a243224369edb837843d9514fdd20fd834b89ef /source/blender/blenkernel/intern/particle_system.c
parent1727a165dd165d2ce392e7a31691db19fb093a5f (diff)
Separate context freeing from task freeing in threaded particle updates
to prevent double-freeing/invalid mem access. This can happen with the "virtual parents" feature, which generates both parent and child paths. Each task free function also freed the shared context, leading to double freeing.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r--source/blender/blenkernel/intern/particle_system.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 93eb273fc00..6e7e341e1cc 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -471,13 +471,24 @@ void psys_tasks_create(ParticleThreadContext *ctx, int totpart, ParticleTask **r
void psys_tasks_free(ParticleTask *tasks, int numtasks)
{
- ParticleThreadContext *ctx;
int i;
if (numtasks == 0)
return;
- ctx = tasks[0].ctx;
+ /* threads */
+ for (i = 0; i < numtasks; ++i) {
+ if (tasks[i].rng)
+ BLI_rng_free(tasks[i].rng);
+ if (tasks[i].rng_path)
+ BLI_rng_free(tasks[i].rng_path);
+ }
+
+ MEM_freeN(tasks);
+}
+
+void psys_thread_context_free(ParticleThreadContext *ctx)
+{
/* path caching */
if (ctx->vg_length)
MEM_freeN(ctx->vg_length);
@@ -506,16 +517,6 @@ void psys_tasks_free(ParticleTask *tasks, int numtasks)
if (ctx->seams) MEM_freeN(ctx->seams);
//if (ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_free(ctx->tree);
-
- /* threads */
- for (i = 0; i < numtasks; ++i) {
- if (tasks[i].rng)
- BLI_rng_free(tasks[i].rng);
- if (tasks[i].rng_path)
- BLI_rng_free(tasks[i].rng_path);
- }
-
- MEM_freeN(tasks);
}
static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p)