From 8aeb9e1abeebf847686a74e24d93964e01f5d4c7 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Thu, 28 Aug 2025 18:57:11 +0200 Subject: [PATCH] bugfix in PS pointer alignment - bug was leading to crashes when heap is low --- wled00/FXparticleSystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/FXparticleSystem.cpp b/wled00/FXparticleSystem.cpp index 21061a098..8b684a5f6 100644 --- a/wled00/FXparticleSystem.cpp +++ b/wled00/FXparticleSystem.cpp @@ -1118,7 +1118,7 @@ bool initParticleSystem2D(ParticleSystem2D *&PartSys, uint32_t requestedsources, allocsuccess = true; break; // allocation succeeded } - numparticles /= 2; // cut number of particles in half and try again + numparticles = ((numparticles / 2) + 3) & ~0x03; // cut number of particles in half and try again, must be 4 byte aligned PSPRINTLN(F("PS 2D alloc failed, trying with less particles...")); } if (!allocsuccess) { @@ -1815,7 +1815,7 @@ bool initParticleSystem1D(ParticleSystem1D *&PartSys, const uint32_t requestedso allocsuccess = true; break; // allocation succeeded } - numparticles /= 2; // cut number of particles in half and try again + numparticles = ((numparticles / 2) + 3) & ~0x03; // cut number of particles in half and try again, must be 4 byte aligned PSPRINTLN(F("PS 1D alloc failed, trying with less particles...")); } if (!allocsuccess) {