From 79bc9a6b946e638b3610a05cf45e63c20bf53ab0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:22:48 +0100 Subject: [PATCH] Fix LList insertAt skipping one entry --- lib/default/TasmotaLList/src/LList.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/default/TasmotaLList/src/LList.h b/lib/default/TasmotaLList/src/LList.h index fc3a7b559..4c2d2c656 100644 --- a/lib/default/TasmotaLList/src/LList.h +++ b/lib/default/TasmotaLList/src/LList.h @@ -208,6 +208,10 @@ T & LList::addToLast(void) { template T & LList::insertAt(size_t index) { + if (0 == index) { + return addHead(); // insert at the head + } + index--; LList_elt **curr_ptr = &_head; size_t count = 0; while (*curr_ptr) {