Skip to content

Commit 9229f87

Browse files
committed
Initialize characteristic array to NULL to prevent crash.
Espressif introduced a new member to the characteristic struct for the characteristic presentation format descriptor, cpfd (0x2904). If this is not initilaized to NULL then the garbage data will be used and subsequently cause a crash on starting the server.
1 parent c8cad35 commit 9229f87

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NimBLEService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ bool NimBLEService::start() {
159159
// Nimble requires the last characteristic to have it's uuid = 0 to indicate the end
160160
// of the characteristics for the service. We create 1 extra and set it to null
161161
// for this purpose.
162-
pChr_a = new ble_gatt_chr_def[numChrs + 1];
162+
pChr_a = new ble_gatt_chr_def[numChrs + 1]{};
163163
int i = 0;
164164
for(auto chr_it = m_chrVec.begin(); chr_it != m_chrVec.end(); ++chr_it) {
165165
if((*chr_it)->m_removed > 0) {

0 commit comments

Comments
 (0)