From fa868568afe82cdb9016fda9c7378c8db3259436 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Mon, 29 Dec 2025 12:56:06 +0100 Subject: [PATCH] minor bugfixes as suggested by the rabbit - PulLightControl UM: dont release a lock you do not own - off-by-one error in extractModeSlider (used only in rotary in UM) - safety check in playlist in case something goes horribly wrong --- .../usermod_v2_HttpPullLightControl.cpp | 1 - wled00/playlist.cpp | 3 ++- wled00/util.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.cpp b/usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.cpp index 44a2726e..c2254a69 100644 --- a/usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.cpp +++ b/usermods/usermod_v2_HttpPullLightControl/usermod_v2_HttpPullLightControl.cpp @@ -284,7 +284,6 @@ void HttpPullLightControl::handleResponse(String& responseStr) { if (!requestJSONBufferLock(myLockId)) { DEBUG_PRINT(F("ERROR: Can not request JSON Buffer Lock, number: ")); DEBUG_PRINTLN(myLockId); - releaseJSONBufferLock(); // Just release in any case, maybe there was already a buffer lock return; } diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index 2e51503e..253c980b 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -89,7 +89,8 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) { it++; } } - for (int i = it; i < playlistLen; i++) playlistEntries[i].dur = playlistEntries[it -1].dur; + if (it > 0) // should never happen but just in case + for (int i = it; i < playlistLen; i++) playlistEntries[i].dur = playlistEntries[it -1].dur; it = 0; JsonArray tr = playlistObj[F("transition")]; diff --git a/wled00/util.cpp b/wled00/util.cpp index 1330bb6c..8a29131a 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -336,7 +336,7 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL case 0: strncpy_P(dest, PSTR("FX Speed"), maxLen); break; case 1: strncpy_P(dest, PSTR("FX Intensity"), maxLen); break; } - dest[maxLen] = '\0'; // strncpy does not necessarily null terminate string + dest[maxLen-1] = '\0'; // strncpy does not necessarily null terminate string } } return strlen(dest);