Skip to content

Commit

Permalink
Initialize ble_gatt_chr_def[]. Fixes #148 (#150)
Browse files Browse the repository at this point in the history
IDF 5.2 introduced a new member, cpfd, to the
ble_gatt_chr_def struct. It needs to be initialized
to nullptr in order to avoid accessing uninitialized
memory. By initializing the whole struct, we get
everything initialized in a backward-compatible way.
  • Loading branch information
holdersn authored and h2zero committed Jun 2, 2024
1 parent c864086 commit 71aa020
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 71aa020

Please sign in to comment.