From 8ca8241547e856eb6fa478ac61de97c0bd720213 Mon Sep 17 00:00:00 2001 From: joyfullservice Date: Wed, 25 Sep 2024 15:07:13 -0500 Subject: [PATCH] Resolve null pointer exception Adding a separator using `ESPUI.separator("Separator name");` triggers an exception when the code tries to access the property of an invalid object. --- src/ESPUI.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ESPUI.cpp b/src/ESPUI.cpp index 211fb74..1db326f 100644 --- a/src/ESPUI.cpp +++ b/src/ESPUI.cpp @@ -531,7 +531,14 @@ uint16_t ESPUIClass::addControl( NotifyClients(ClientUpdateType_t::RebuildNeeded); - return control->id; + if (control == nullptr) + { + return 0; + } + else + { + return control->id; + } } bool ESPUIClass::removeControl(uint16_t id, bool force_rebuild_ui)