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:
authorJacques Lucke <jacques@blender.org>2021-01-05 18:17:21 +0300
committerJacques Lucke <jacques@blender.org>2021-01-05 18:17:37 +0300
commit357e519575411cc338acfe899fde6e5ea3476801 (patch)
tree08c48158c9b3f121c591515e371fb601601e3f07
parentcffa39358faa0c365cf12f9dc72eb138d823767a (diff)
Fix T83282: division by zero when creating psys tasks
-rw-r--r--source/blender/blenkernel/intern/particle_system.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 71df28c8b42..ad98079bc27 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -475,15 +475,15 @@ void psys_tasks_create(ParticleThreadContext *ctx,
{
ParticleTask *tasks;
int numtasks = min_ii(BLI_system_thread_count() * 4, endpart - startpart);
- float particles_per_task = (float)(endpart - startpart) / (float)numtasks, p, pnext;
- int i;
+ float particles_per_task = numtasks > 0 ? (float)(endpart - startpart) / (float)numtasks : 0;
tasks = MEM_callocN(sizeof(ParticleTask) * numtasks, "ParticleThread");
*r_numtasks = numtasks;
*r_tasks = tasks;
- p = (float)startpart;
- for (i = 0; i < numtasks; i++, p = pnext) {
+ float pnext;
+ float p = (float)startpart;
+ for (int i = 0; i < numtasks; i++, p = pnext) {
pnext = p + particles_per_task;
tasks[i].ctx = ctx;