diff --git a/src/NimBLEAdvertising.cpp b/src/NimBLEAdvertising.cpp index af98b34..4dd5a39 100644 --- a/src/NimBLEAdvertising.cpp +++ b/src/NimBLEAdvertising.cpp @@ -138,7 +138,7 @@ void NimBLEAdvertising::addTxPower() { */ void NimBLEAdvertising::setName(const std::string &name) { m_name.assign(name.begin(), name.end()); - m_name[name.length()] = 0; + if (name.length() <= 19) m_name[name.length()] = 0; m_advData.name = &m_name[0]; m_advData.name_len = m_name.size(); m_advDataSet = false;