From f86a14ceabc9a491a197416dea015472bb18f10e Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Thu, 12 Aug 2021 21:17:40 +0100 Subject: [PATCH] Servo profile - avoid overrun of array bounds. --- IO_PCA9685.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IO_PCA9685.cpp b/IO_PCA9685.cpp index a6bde29..dd2a607 100644 --- a/IO_PCA9685.cpp +++ b/IO_PCA9685.cpp @@ -129,7 +129,7 @@ void PCA9685::_write(VPIN vpin, int value) { s->numSteps = profile==Fast ? 10 : profile==Medium ? 20 : profile==Slow ? 40 : - profile==Bounce ? sizeof(_bounceProfile) : + profile==Bounce ? sizeof(_bounceProfile)-1 : 1; s->state = value; s->stepNumber = 0; @@ -163,7 +163,7 @@ void PCA9685::_writeAnalogue(VPIN vpin, int value, int profile) { s->numSteps = profile==Fast ? 10 : profile==Medium ? 20 : profile==Slow ? 40 : - profile==Bounce ? sizeof(_bounceProfile) : + profile==Bounce ? sizeof(_bounceProfile)-1 : 1; s->stepNumber = 0; s->toPosition = min(value, 4095);