Skip to content

Commit 71aa020

Browse files
holdersnh2zero
authored andcommitted
Initialize ble_gatt_chr_def[]. Fixes #148 (#150)
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.
1 parent c864086 commit 71aa020

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)