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; }