inactive segments robustness improvement

* Avoid uint16 underflow in width() and height(): stop > start is possible, and means "inactive segment".

Without these checks, it was possible that width() and height() produce VERY large values due to underflow.
This commit is contained in:
Frank
2023-07-03 15:43:47 +02:00
parent eabd6f60ef
commit 406a254523
3 changed files with 5 additions and 4 deletions

View File

@@ -729,7 +729,7 @@ uint32_t Segment::getPixelColor(int i)
i += start;
/* offset/phase */
i += offset;
if (i >= stop) i -= length();
if ((i >= stop) && (stop>0)) i -= length(); // avoids negative pixel index (stop = 0 is a possible value)
return strip.getPixelColor(i);
}