Skip to content

Commit

Permalink
Initialize characteristic array to NULL to prevent crash.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
h2zero committed Jun 14, 2024
1 parent be9b2eb commit e761e4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NimBLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool NimBLEService::start() {
// Nimble requires the last characteristic to have it's uuid = 0 to indicate the end
// of the characteristics for the service. We create 1 extra and set it to null
// for this purpose.
pChr_a = new ble_gatt_chr_def[numChrs + 1];
pChr_a = new ble_gatt_chr_def[numChrs + 1]{};
int i = 0;
for(auto chr_it = m_chrVec.begin(); chr_it != m_chrVec.end(); ++chr_it) {
if((*chr_it)->m_removed > 0) {
Expand Down

0 comments on commit e761e4a

Please sign in to comment.