From cfebb456e41bfd337774bcc8dbbedb6e52d16a52 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:24:53 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20[security=20fix]=20Initialize=20?= =?UTF-8?q?stateChanged=20in=20constructor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎯 What: Initialize the `stateChanged` member variable in the ABounce constructor. ⚠️ Risk: The `stateChanged` variable was previously uninitialized, leading to undefined behavior. This could cause `risingEdge()` or `fallingEdge()` to return true incorrectly upon object creation if the memory contains non-zero data, potentially triggering erroneous logic in applications using this library. 🛡️ Solution: Added `stateChanged = 0;` to the ABounce constructor in ABounce.cpp to ensure it starts in a known state. Co-authored-by: prestalab <2825421+prestalab@users.noreply.github.com> --- ABounce.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ABounce.cpp b/ABounce.cpp index b763225..ebf0d79 100644 --- a/ABounce.cpp +++ b/ABounce.cpp @@ -11,7 +11,8 @@ ABounce::ABounce(uint8_t pin,unsigned long interval_millis) interval(interval_millis); previous_millis = millis(); state = getButton(analogRead(pin)); - this->pin = pin; + this->pin = pin; + stateChanged = 0; } int ABounce::getButton(int buttonValue)