From 89bf89f1532931b64f65365137221759566ecea7 Mon Sep 17 00:00:00 2001 From: h2zero Date: Tue, 18 Jan 2022 14:44:47 -0700 Subject: [PATCH] Fix memory leak when services changed. --- src/NimBLEService.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NimBLEService.cpp b/src/NimBLEService.cpp index 18e15bc..f8cd0f6 100644 --- a/src/NimBLEService.cpp +++ b/src/NimBLEService.cpp @@ -113,6 +113,12 @@ bool NimBLEService::start() { // Rebuild the service definition if the server attributes have changed. if(getServer()->m_svcChanged && m_pSvcDef != nullptr) { + if(m_pSvcDef[0].characteristics) { + if(m_pSvcDef[0].characteristics[0].descriptors) { + delete(m_pSvcDef[0].characteristics[0].descriptors); + } + delete(m_pSvcDef[0].characteristics); + } delete(m_pSvcDef); m_pSvcDef = nullptr; }